This content has been marked as final.
Show 10 replies
-
1. Re: Default JNDI naming scheme in EJB3.0 and possible confli
jaikiran Oct 18, 2008 8:33 AM (in response to jaikiran)Thinking more about this, the conflict can arise even when there are 2 beans with the same classname (but different package names) in the same jar.
Ex:
MyApp.ear/Single.jarpackage org.myapp.business; @Stateless public class ManagerBean implements org.myapp.business.Manager { }
package org.myapp.persistence; @Stateless public class ManagerBean implements org.myapp.persistence.Manager { }
-
2. Re: Default JNDI naming scheme in EJB3.0 and possible confli
wolfc Oct 21, 2008 10:57 AM (in response to jaikiran)The first example is a pain, which is easily circumvented by setting another JNDI policy. Which will be the cases when we go 3.1.
The second example will even fail in 3.1, but I consider it bad practice to have two classes with the same name in 1 module. -
3. Re: Default JNDI naming scheme in EJB3.0 and possible confli
alrubinger Oct 21, 2008 11:18 AM (in response to jaikiran)This is all just because we default the EJB Name in the case it's not specified.
So the workaround is to set it explicitly.
Otherwise we could default the EJB Name to the FQN of the bean impl class, but I think that'll cause more problems (migration) that it'll solve.
S,
ALR -
4. Re: Default JNDI naming scheme in EJB3.0 and possible confli
jaikiran Oct 21, 2008 11:43 AM (in response to jaikiran)"wolfc" wrote:
The second example will even fail in 3.1, but I consider it bad practice to have two classes with the same name in 1 module.
I think the second example will be handled gracefully in 3.1 as per the specs (Section 4.4.1):Each portable session bean global JNDI name has the following syntax :
java:global[/<app-name>]/<module-name>/<bean-name>#<fully-qualified-interface-name>
The container registers a separate global JNDI name entry for each local business interface, each remote business interface, and any no-interface view, 2.x local home interface, or 2.x remote home interface. For the the no-interface view, the last portion of the entry name is the fully-qualified bean class name.
The fully-qualified-interface-name will generate a unique JNDI name."ALRubinger" wrote:
Otherwise we could default the EJB Name to the FQN of the bean impl class, but I think that'll cause more problems (migration) that it'll solve.
I agree - changing the default EJB name at this point would not be of much help for this not so common scenario."ALRubinger" wrote:
So the workaround is to set it explicitly.
Right, but the current behaviour just silently ignores the 2nd EJB and does not bind it. So if we have the information that we have already bound bean1 to the same name then maybe we could log a WARN message to highlight this issue so that the user opts for the workaround.
-
5. Re: Default JNDI naming scheme in EJB3.0 and possible confli
jaikiran Oct 21, 2008 12:27 PM (in response to jaikiran)"jaikiran" wrote:
I think the second example will be handled gracefully in 3.1 as per the specs (Section 4.4.1):Each portable session bean global JNDI name has the following syntax :
java:global[/<app-name>]/<module-name>/<bean-name>#<fully-qualified-interface-name>
The container registers a separate global JNDI name entry for each local business interface, each remote business interface, and any no-interface view, 2.x local home interface, or 2.x remote home interface. For the the no-interface view, the last portion of the entry name is the fully-qualified bean class name.
The fully-qualified-interface-name will generate a unique JNDI name.
On second thoughts, Carlo is right. The following scenario will not work even in 3.1:
Both packaged in same EAR/JAR:
package org.myapp.business; @Stateless public class ManagerBean implements org.myapp.Manager { }
package org.myapp.persistence; @Stateless public class ManagerBean implements org.myapp.Manager { }
Both of these will resolve tojava:global[/<app-name>]/<module-name>/ManagerBean#org.myapp.Manager
-
6. Re: Default JNDI naming scheme in EJB3.0 and possible confli
alrubinger Oct 22, 2008 5:40 PM (in response to jaikiran)"jaikiran" wrote:
Right, but the current behaviour just silently ignores the 2nd EJB and does not bind it.
There's no exception thrown when binding to an already bound address?"jaikiran" wrote:
So if we have the information that we have already bound bean1 to the same name then maybe we could log a WARN message to highlight this issue so that the user opts for the workaround.
Better to fail the whole deployment w/ a descriptive exception.
S,
ALR -
7. Re: Default JNDI naming scheme in EJB3.0 and possible confli
jaikiran Oct 23, 2008 5:14 AM (in response to jaikiran)"ALRubinger" wrote:
There's no exception thrown when binding to an already bound address?
No exceptions in JBoss AS 4.2.3 GA. Fails with exception on deployment on JBoss-5 CR2.
Going by the logs looks like something to do with the org.jboss.ejb3.stateless.BaseStatelessProxyFactory which is doing with binding in 4.2.3 GA. Let me setup the 4.2.3 source code to dig more into this. -
8. Re: Default JNDI naming scheme in EJB3.0 and possible confli
jaikiran Oct 23, 2008 7:05 AM (in response to jaikiran)"jaikiran" wrote:
No exceptions in JBoss AS 4.2.3 GA.
Going by the logs looks like something to do with the org.jboss.ejb3.stateless.BaseStatelessProxyFactory which is doing with binding in 4.2.3 GA. Let me setup the 4.2.3 source code to dig more into this.
Found this in org.jboss.ejb3.stateless.BaseStatelessProxyFactoryprotected void bindProxy(Object proxy) throws NamingException { try { log.debug("Binding proxy for " + getContainer().getEjbName() + " in JNDI at " + jndiName); Util.rebind(getContainer().getInitialContext(), jndiName, proxy); } catch (NamingException e) { NamingException namingException = new NamingException("Could not bind stateless proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName); namingException.setRootCause(e); throw namingException; } }
For some reason Util.rebind is being used instead of Util.bind. That explains why the exception is not thrown.
Do you think it was intentional to use rebind for some reason? If not, do you want me to create a JIRA to fix this? -
9. Re: Default JNDI naming scheme in EJB3.0 and possible confli
alrubinger Oct 23, 2008 12:28 PM (in response to jaikiran)"jaikiran" wrote:
If not, do you want me to create a JIRA to fix this?
Well, Branch_4_2 is dead (meaning no more releases from there) so I wouldn't much see the point... :)
S,
ALR -
10. Re: Default JNDI naming scheme in EJB3.0 and possible confli
jaikiran Oct 24, 2008 2:08 AM (in response to jaikiran)Okay :)