Discussion:
NameAlreadyBoundException when deploying as EAR
otbutz
2018-01-17 09:08:42 UTC
Permalink
Hey there,

we're currently reworking our deployment and have switched to EAR with our
project. When starting up our TomEE 1.7.4 applicationserver the deployment
of the EJB projects works flawlessly and without any warnings but the
webapps in the EAR cause the following exceptions in the console:

e.g:

javax.naming.NameAlreadyBoundException: ParsedName{path=GeoCode,
component=GeoCode}
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:158)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:168)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:168)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:168)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.IvmContext.bind(IvmContext.java:308)
at
org.apache.openejb.core.ivm.naming.IvmContext.rebind(IvmContext.java:322)
at
org.apache.openejb.assembler.classic.Assembler.bindGlobals(Assembler.java:1188)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1379)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Our service works without any problems but the errors are a bit annoying. It
seems like the webappbuilder tries to register our EJBs again in the webapps
but fails to do so.

I've searched the net quite a lot and found some threads but none of those
fit our case. I would like to submit a minimal example but i'm afraid to
violate corporate policies. I will try my best to answer any upcoming
questions though!



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-01-17 09:23:45 UTC
Permalink
Hi

if you customized EJB deploymentId with the corresponding property to not
be ambiguous accross ear modules/webapps then it can be a bug fixed on the
7.x we never backported. This part was improved quite a lot on 7.x


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau>
Post by otbutz
Hey there,
we're currently reworking our deployment and have switched to EAR with our
project. When starting up our TomEE 1.7.4 applicationserver the deployment
of the EJB projects works flawlessly and without any warnings but the
javax.naming.NameAlreadyBoundException: ParsedName{path=GeoCode,
component=GeoCode}
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:158)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:168)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:168)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:168)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:175)
at
org.apache.openejb.core.ivm.naming.IvmContext.bind(IvmContext.java:308)
at
org.apache.openejb.core.ivm.naming.IvmContext.rebind(IvmContext.java:322)
at
org.apache.openejb.assembler.classic.Assembler.bindGlobals(
Assembler.java:1188)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(
TomcatWebAppBuilder.java:1379)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(
TomcatWebAppBuilder.java:1100)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(
GlobalListenerSupport.java:130)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
LifecycleSupport.java:117)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(
LifecycleBase.java:90)
at
org.apache.catalina.core.StandardContext.startInternal(
StandardContext.java:5472)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at
org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1572)
at
org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Our service works without any problems but the errors are a bit annoying. It
seems like the webappbuilder tries to register our EJBs again in the webapps
but fails to do so.
I've searched the net quite a lot and found some threads but none of those
fit our case. I would like to submit a minimal example but i'm afraid to
violate corporate policies. I will try my best to answer any upcoming
questions though!
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
f979441.html
otbutz
2018-01-17 09:42:16 UTC
Permalink
Are you refering to the openejb.deploymentId.format property?
We're currently using the default format. Could this be the root of our
problem?



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-01-17 09:52:59 UTC
Permalink
It can if multiple modules deploy the same EJB


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau>
Post by otbutz
Are you refering to the openejb.deploymentId.format property?
We're currently using the default format. Could this be the root of our
problem?
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
f979441.html
otbutz
2018-01-17 10:15:19 UTC
Permalink
The EJBs lie in their own modules and are only used by the webapps through
injection.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Paul Carter-Brown
2018-01-17 18:57:09 UTC
Permalink
Try adding this to your setenv.sh or changes system.properties accordingly:

-Dopenejb.deploymentId.format={appId}/{ejbJarId}/{ejbName}
-Dopenejb.wsAddress.format={ejbName}

That will make your deployement Id's for EJB's include the app/jar names
and won't impact any web service endpoints you may have.
Post by otbutz
The EJBs lie in their own modules and are only used by the webapps through
injection.
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
f979441.html
otbutz
2018-01-18 13:01:59 UTC
Permalink
Unaltered behaviour.

Checked the corresponding source of openejb-core 4.7.4:

public void bindGlobals(Map<String, Object> bindings) throws NamingException
{
Context containerSystemContext = this.containerSystem.getJNDIContext();
for (Map.Entry<String, Object> value : bindings.entrySet()) {
String path = (String) value.getKey();
if ((!path.startsWith("module/")) && (!path.startsWith("app/")) &&
(!path.startsWith("comp/"))
&& (!path.equalsIgnoreCase("global/dummy"))) {
Context lastContext =
Contexts.createSubcontexts(containerSystemContext, path);
try {
lastContext.rebind(path.substring(path.lastIndexOf("/") + 1,
path.length()), value.getValue());
} catch (NameAlreadyBoundException nabe) {
nabe.printStackTrace(); // the observed output in the
console
}
containerSystemContext.rebind(path, value.getValue());
}
}
}


1. Why is my webapp even trying to rebind the JNDI entry of my beans?
2. Shouldn't a "rebind" not fail if something is already there?



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-01-18 15:10:34 UTC
Permalink
well it depends the rebind. Keep in ming this is an internal part so not
respecting the rebind API contract is fine *here*.

the idea of this code is to merge tomee and tomcat JNDI models to have the
lookups unified (EE and servlet integration if you want).


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau>
Post by otbutz
Unaltered behaviour.
public void bindGlobals(Map<String, Object> bindings) throws
NamingException
{
Context containerSystemContext = this.containerSystem.
getJNDIContext();
for (Map.Entry<String, Object> value : bindings.entrySet()) {
String path = (String) value.getKey();
if ((!path.startsWith("module/")) && (!path.startsWith("app/")) &&
(!path.startsWith("comp/"))
&& (!path.equalsIgnoreCase("global/dummy"))) {
Context lastContext =
Contexts.createSubcontexts(containerSystemContext, path);
try {
lastContext.rebind(path.substring(path.lastIndexOf("/") + 1,
path.length()), value.getValue());
} catch (NameAlreadyBoundException nabe) {
nabe.printStackTrace(); // the observed output in the
console
}
containerSystemContext.rebind(path, value.getValue());
}
}
}
1. Why is my webapp even trying to rebind the JNDI entry of my beans?
2. Shouldn't a "rebind" not fail if something is already there?
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
f979441.html
otbutz
2018-01-18 16:12:30 UTC
Permalink
That answers question number 2 but why is the rebind happening at all?
The beans already exist and are registered within the context otherwise the
error wouldn't be thrown. Shouldn't the webappbuilder just pick up the
existing bean and be done with it?

I just want to rule out any errors in our project setup before i invest time
into upgrading everything to TomEE 7.

Thanks so far for all the answers :)



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-01-18 16:27:48 UTC
Permalink
Post by otbutz
That answers question number 2 but why is the rebind happening at all?
The beans already exist and are registered within the context otherwise the
error wouldn't be thrown. Shouldn't the webappbuilder just pick up the
existing bean and be done with it?
Not, it can happen it is not the right one and we need to enforce it. Would
need to check again since we upgrade numerous tomcat versions but was
happening years ago.
Post by otbutz
I just want to rule out any errors in our project setup before i invest time
into upgrading everything to TomEE 7.
Sometimes it is faster to do the opposite so maybe give it a time-boxed try
;)
Post by otbutz
Thanks so far for all the answers :)
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
f979441.html
Loading...