You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2016/02/08 13:19:00 UTC
[1/2] tomee git commit: Don't initialize uninitialized resources when
destroying the application
Repository: tomee
Updated Branches:
refs/heads/tomee-1.7.x ee20b46c9 -> a2bbedf12
Don't initialize uninitialized resources when destroying the application
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2631d5aa
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2631d5aa
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2631d5aa
Branch: refs/heads/tomee-1.7.x
Commit: 2631d5aae5c8aab4a297e8b9c622a81a078a412d
Parents: ee20b46
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Fri Feb 5 13:45:49 2016 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Fri Feb 5 13:45:49 2016 +0000
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 44 ++++++++++++++++++--
1 file changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/2631d5aa/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 007fa78..d00b470 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1114,7 +1114,8 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
}
}
} catch (final Exception e) {
- logger.fatal("Error calling @PostConstruct method on " + resourceInfo.id);
+ logger.fatal("Error calling PostConstruct method on " + resourceInfo.id);
+ logger.fatal("Resource " + resourceInfo.id + " could not be initialized. Application will be undeployed.");
throw new OpenEJBException(e);
}
}
@@ -2196,8 +2197,45 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
}
private void destroyLookedUpResource(final Context globalContext, final String id, final String name) throws NamingException {
- final Object object = globalContext.lookup(name);
- final String clazz;
+
+ Object object = null;
+
+ try {
+ object = globalContext.lookup(name);
+ } catch (NamingException e) {
+ // if we catch a NamingException, check to see if the resource is a LaztObjectReference that has not been initialized correctly
+ final String ctx = name.substring(0, name.lastIndexOf("/"));
+ final String objName = name.substring(ctx.length() + 1);
+ final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
+ while (bindings.hasMoreElements()) {
+ final Binding binding = bindings.nextElement();
+ if (!binding.getName().equals(objName)) continue;
+ if (!LazyObjectReference.class.isInstance(binding.getObject())) continue;
+
+ final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
+ if (! ref.isInitialized()) {
+ globalContext.unbind(name);
+
+ // TODO: refactor this method out
+ //Ensure ResourceInfo for this resource is removed
+ final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
+ final Iterator<ResourceInfo> iterator = configuration.facilities.resources.iterator();
+ while (iterator.hasNext()) {
+ final ResourceInfo info = iterator.next();
+ if (name.equals(OPENEJB_RESOURCE_JNDI_PREFIX + info.id)) {
+ iterator.remove();
+ break;
+ }
+ }
+
+ return;
+ }
+ }
+
+ throw e;
+ }
+
+ final String clazz;
if (object == null) { // should it be possible?
clazz = "?";
} else {
Fwd: [2/2] tomee git commit: Refactor + spacing
Posted by Romain Manni-Bucau <rm...@gmail.com>.
If it can help - didnt investigate if it was 100% valid - 7.x branch
probably solved it with https://issues.apache.org/jira/browse/TOMEE-1548
(isInitialized() method in lazy resource)
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>
---------- Forwarded message ----------
From: <jg...@apache.org>
Date: 2016-02-08 13:19 GMT+01:00
Subject: [2/2] tomee git commit: Refactor + spacing
To: commits@tomee.apache.org
Refactor + spacing
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a2bbedf1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a2bbedf1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a2bbedf1
Branch: refs/heads/tomee-1.7.x
Commit: a2bbedf12d33d887116761b90df6ae7f3cf9d06e
Parents: 2631d5a
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Mon Feb 8 11:04:40 2016 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Feb 8 11:04:40 2016 +0000
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 70 +++++++++-----------
1 file changed, 31 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/a2bbedf1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index d00b470..91b4f7a 100644
---
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1782,6 +1782,10 @@ public class Assembler extends AssemblerTool
implements org.apache.openejb.spi.A
logger.debug("Not processing resource on destroy: " +
className);
}
+ removeResourceInfo(name);
+ }
+
+ public void removeResourceInfo(final String name) {
try {
//Ensure ResourceInfo for this resource is removed
final OpenEjbConfiguration configuration =
SystemInstance.get().getComponent(OpenEjbConfiguration.class);
@@ -2197,45 +2201,33 @@ public class Assembler extends AssemblerTool
implements org.apache.openejb.spi.A
}
private void destroyLookedUpResource(final Context globalContext,
final String id, final String name) throws NamingException {
-
- Object object = null;
-
- try {
- object = globalContext.lookup(name);
- } catch (NamingException e) {
- // if we catch a NamingException, check to see if
the resource is a LaztObjectReference that has not been initialized
correctly
- final String ctx = name.substring(0,
name.lastIndexOf("/"));
- final String objName = name.substring(ctx.length()
+ 1);
- final NamingEnumeration<Binding> bindings =
globalContext.listBindings(ctx);
- while (bindings.hasMoreElements()) {
- final Binding binding =
bindings.nextElement();
- if (!binding.getName().equals(objName))
continue;
- if
(!LazyObjectReference.class.isInstance(binding.getObject())) continue;
-
- final LazyObjectReference<?> ref =
LazyObjectReference.class.cast(binding.getObject());
- if (! ref.isInitialized()) {
- globalContext.unbind(name);
-
- // TODO: refactor this method out
- //Ensure ResourceInfo for this
resource is removed
- final OpenEjbConfiguration configuration =
SystemInstance.get().getComponent(OpenEjbConfiguration.class);
- final Iterator<ResourceInfo> iterator =
configuration.facilities.resources.iterator();
- while (iterator.hasNext()) {
- final ResourceInfo info = iterator.next();
- if
(name.equals(OPENEJB_RESOURCE_JNDI_PREFIX + info.id)) {
- iterator.remove();
- break;
- }
- }
-
- return;
- }
- }
-
- throw e;
- }
-
- final String clazz;
+
+ Object object = null;
+
+ try {
+ object = globalContext.lookup(name);
+ } catch (NamingException e) {
+ // if we catch a NamingException, check to see if the resource
is a LaztObjectReference that has not been initialized correctly
+ final String ctx = name.substring(0, name.lastIndexOf("/"));
+ final String objName = name.substring(ctx.length() + 1);
+ final NamingEnumeration<Binding> bindings =
globalContext.listBindings(ctx);
+ while (bindings.hasMoreElements()) {
+ final Binding binding = bindings.nextElement();
+ if (!binding.getName().equals(objName)) continue;
+ if
(!LazyObjectReference.class.isInstance(binding.getObject())) continue;
+
+ final LazyObjectReference<?> ref =
LazyObjectReference.class.cast(binding.getObject());
+ if (! ref.isInitialized()) {
+ globalContext.unbind(name);
+ removeResourceInfo(name);
+ return;
+ }
+ }
+
+ throw e;
+ }
+
+ final String clazz;
if (object == null) { // should it be possible?
clazz = "?";
} else {
[2/2] tomee git commit: Refactor + spacing
Posted by jg...@apache.org.
Refactor + spacing
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a2bbedf1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a2bbedf1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a2bbedf1
Branch: refs/heads/tomee-1.7.x
Commit: a2bbedf12d33d887116761b90df6ae7f3cf9d06e
Parents: 2631d5a
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Mon Feb 8 11:04:40 2016 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Feb 8 11:04:40 2016 +0000
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 70 +++++++++-----------
1 file changed, 31 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/a2bbedf1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index d00b470..91b4f7a 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1782,6 +1782,10 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
logger.debug("Not processing resource on destroy: " + className);
}
+ removeResourceInfo(name);
+ }
+
+ public void removeResourceInfo(final String name) {
try {
//Ensure ResourceInfo for this resource is removed
final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
@@ -2197,45 +2201,33 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
}
private void destroyLookedUpResource(final Context globalContext, final String id, final String name) throws NamingException {
-
- Object object = null;
-
- try {
- object = globalContext.lookup(name);
- } catch (NamingException e) {
- // if we catch a NamingException, check to see if the resource is a LaztObjectReference that has not been initialized correctly
- final String ctx = name.substring(0, name.lastIndexOf("/"));
- final String objName = name.substring(ctx.length() + 1);
- final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
- while (bindings.hasMoreElements()) {
- final Binding binding = bindings.nextElement();
- if (!binding.getName().equals(objName)) continue;
- if (!LazyObjectReference.class.isInstance(binding.getObject())) continue;
-
- final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
- if (! ref.isInitialized()) {
- globalContext.unbind(name);
-
- // TODO: refactor this method out
- //Ensure ResourceInfo for this resource is removed
- final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
- final Iterator<ResourceInfo> iterator = configuration.facilities.resources.iterator();
- while (iterator.hasNext()) {
- final ResourceInfo info = iterator.next();
- if (name.equals(OPENEJB_RESOURCE_JNDI_PREFIX + info.id)) {
- iterator.remove();
- break;
- }
- }
-
- return;
- }
- }
-
- throw e;
- }
-
- final String clazz;
+
+ Object object = null;
+
+ try {
+ object = globalContext.lookup(name);
+ } catch (NamingException e) {
+ // if we catch a NamingException, check to see if the resource is a LaztObjectReference that has not been initialized correctly
+ final String ctx = name.substring(0, name.lastIndexOf("/"));
+ final String objName = name.substring(ctx.length() + 1);
+ final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
+ while (bindings.hasMoreElements()) {
+ final Binding binding = bindings.nextElement();
+ if (!binding.getName().equals(objName)) continue;
+ if (!LazyObjectReference.class.isInstance(binding.getObject())) continue;
+
+ final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
+ if (! ref.isInitialized()) {
+ globalContext.unbind(name);
+ removeResourceInfo(name);
+ return;
+ }
+ }
+
+ throw e;
+ }
+
+ final String clazz;
if (object == null) { // should it be possible?
clazz = "?";
} else {