@PersistenceContext injection from a different jar fails
nouredine13 Nov 25, 2008 6:22 AMHello,
I have a sample application with an EJB3 SLSB which is being injected with a PersistenceContext which is configured in a different jar file as follows :
package org.myapp.ejb.impl;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.myapp.ejb.AppManager;
@Stateless
@Local ({AppManager.class})
public class AppManagerBean implements AppManager {
@PersistenceContext (unitName="myapp_ejb3.jar#MyPU")
private EntityManager em;
public String getVersion() {
System.out.println("EM is " + em);
return "1.0";
}
}
The application is deployed as an EAR file in the following structure:
EJB3Persistence.ear
|
|--- META-INF
| |
| |----application.xml
| |
|--- myapp_ejb3.jar (contains the persistence.xml)
| |
| |--- META-INF
| | |
| | |--- persistence.xml
|
|
|
|--- another_ejb3.jar (contains the SLSB)
| |
| |
| |--- META-INF
| |
| |--- org.myapp.ejb.impl.AppManagerBean
Note that this application is deployed fine in JBoss-5.0.0.Beta4,
but with 5.0.0.CR2 the deployment fails.
Part of the exception is pasted below:
Caused by: java.lang.IllegalArgumentException: Can't find a deployment unit named myapp_ejb3.jar at AbstractVFSDeploymentContext@25710991{vfszip:/product/jboss/jboss-5.0.0.CR2/server/default/deploy/EJB3Persistence.ear/another_ejb3.jar}
at org.jboss.jpa.resolvers.DefaultPersistenceUnitDependencyResolver.getDeploymentUnit(DefaultPersistenceUnitDependencyResolver.java:106)
at org.jboss.jpa.resolvers.DefaultPersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(DefaultPersistenceUnitDependencyResolver.java:131)
at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:841)
at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1399)
at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:124)
at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76)
at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:570)
at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:439)
at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:552)
at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:202)
... 28 more
I found the same bug here : http://www.jboss.com/index.html?module=bb&op=viewtopic&t=146052
I applied the solution he suggested : jboss-JPA-deployers-1.0.0.Beta4, but this do not solve the problem!
if someone has an idea?
Thank's a lot.