[jboss-user] [Installation, Configuration & DEPLOYMENT] - @PersistenceContext injection from a different jar fails

Nouredine13 do-not-reply at jboss.com
Tue Nov 25 06:28:50 EST 2008


Hello,

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 at 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.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192053#4192053

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4192053



More information about the jboss-user mailing list