That's great... I tried it, and the classloading worked as advertised :-)
However, it seems to break EJB injection. Both of my application EARs contain a common ejb-jar withs some basic tools (my DAO ejb and my entities). Trying to inject the DAOEJB results in this:
Caused by: java.lang.RuntimeException: For EJB ReceptionistEJB could not find jn di binding based on interface only for @EJB(com.blorn.entity.dao.DAO) duplicated in entity.jar and entity.jar at org.jboss.ejb3.injection.EJBHandler.getJndiName(EJBHandler.java:216) at org.jboss.ejb3.injection.EJBHandler.loadFieldInjectors(EJBHandler.jav a:326) at org.jboss.ejb3.injection.EJBHandler.loadInjectors(EJBHandler.java:78) at org.jboss.ejb3.injection.EJBHandler.loadInjectors(EJBHandler.java:57) at org.jboss.ejb3.EJBContainer.resolveInjectors(EJBContainer.java:651) at org.jboss.ejb3.EJBContainer.initializePool(EJBContainer.java:586) at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:518) at org.jboss.ejb3.SessionContainer.start(SessionContainer.java:82) at org.jboss.ejb3.stateless.StatelessContainer.start(StatelessContainer. java:80) ... 124 more
This makes some amount of sense because there are two JNDI entries, appA/DAOEJB/local and appB/DAOEJB/local. However, shouldn't the reference within an application's EAR be found first?
Looking at the code for Ejb3Deployment.getEjbJndiName(), it would seem that this should be the case. First the jar of the EJB requesting injection is checked, then all deployments within the EAR containing the requesting EJB, then the global Ejb3Registry. However, when I walk through with a debugger, I find that the second part is not working. The local DAOEJB is not found in the EAR search, but both DAOEJBs are found in the Ejb3Registry. I've checked and rechecked my packaging, but it looks correct.
Is this a bug?
I just stumbled on the same issue within the application I'm developing. When will this bug be solved? It's really a show stopper for us...
Read the issue and the fix for version roadmap.