2 Replies Latest reply on Mar 8, 2011 1:28 PM by Kevin Tee

    MDB in separate jar fails over persistence.xml

    Kevin Tee Newbie

      Hello,

      My application contains two separate jars: 1. Entity Jar with persistence.xml 2. MDB ( shown below)

       

       

      ear
      |-- entities-ejb
      | |-- META-INF
      | | |-- persistence.xml ( defines 'testPU')
      |
      |--
      myMessagingEJB3.jar
      | |-- MyMessageDrivenBean
      |
      |-- war

       

       

      We are in a process of migrating our application to JBOSS 5.1. As suggested, we changed the Annotation class package from org.jboss.annotation to org.jboss.ejb3.annotation (impacting SecurityDomain and ResourceAdapter). Now we are seeing the MDB causing deployment failure. Failure indicates the MDB expecting persistence.xml whihc it should not require.

       

      Here is the exception trace:

       

      16:29:00,766 ERROR [Ejb3Deployment] Exception while processing container metadata for EJB: JPATestDAO in unit: myMessagingEJB3.jar

      16:29:00,782 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/8080_jvm/deploy/myEAR.ear/ state=PreReal mode=Manual requiredState=Real

      org.jboss.deployers.spi.DeploymentException: Error deploying myMessagingEJB3.jar: Exception while processing container metadata for EJB: JPATestDAO in unit: myMessagingEJB3.jar

          at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)

          at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:61)

          at org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer.deploy(AbstractSimpleVFSRealDeployer.java:56)

          at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)

          at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)

          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1454)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1172)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1225)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1113)

          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)

          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:789)

          at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:699)

          at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)

          at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)

          at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)

          at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)

          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543)

          at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)

          at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256)

          at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)

          at org.jboss.Main.boot(Main.java:221)

          at org.jboss.Main$1.run(Main.java:556)

          at java.lang.Thread.run(Thread.java:619)

      Caused by: java.lang.Exception: Exception while processing container metadata for EJB: JPATestDAO in unit: myMessagingEJB3.jar

          at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:551)

          at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)

          ... 35 more

      Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=myEAR.ear,jar=myMessagingEJB3.jar,name=JPATestDAO,service=EJB3 failed to resolve persistence unit TestPU

          at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135)

          at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:183)

          at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:160)

          at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:197)

          at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:631)

          at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:420)

          at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:529)

          ... 36 more

      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'testPU' in AbstractVFSDeploymentContext@32529641{vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/8080_jvm/deploy/myEAR.ear/myMessagingEJB3.jar/}

          at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107)

          at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:778)

          at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1514)

          at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)

          ... 42 more

       

      ANy helps will be much appreciated.

       

      Thanks

      Kevin

        • 1. Re: MDB in separate jar fails over persistence.xml
          jaikiran pai Master

          The JPATestDAO seems to be injecting @PersistenceContext from a different jar. What does that code look like? Since the PU belongs to a different jar, it should be:

           

          @PersistenceContext(unitName="entities-ejb#testPU")

           

           

          By the way, on a different note, if it's an option then use JBoss AS 6.0.0.Final instead of JBoss AS 5.1.0.

          • 2. MDB in separate jar fails over persistence.xml
            Kevin Tee Newbie

            Thanks JaiKiran for the reply. Unfortunately, considering 6.0 is not a possibility in the immediate future.

             

            The intriguing part is: JPATestDAO is actually  part of entities-ejb and not

            myMessagingEJB3.jar but somehow JBOSS 'thinks' JPATestDAO is in myMessagingEJB3.jar.

             

             

             

            "16:29:00,766 ERROR [Ejb3Deployment] Exception while processing container metadata for EJB: JPATestDAO in unit: myMessagingEJB3.jar"

             

             

             

            Because it's part of entities-ejb itself, I have the PersistenceContext defined without the jar qualifier:

             

             

            @Stateless

            public class JPATestDAO implements ITestDAO {

                @PersistenceContext(unitName="testPU")

                private EntityManager em;

             

            Like you suggested, I changed the JPATestDAO so that now it has jar qualifier in @persistenceContext. Now JBOSS identifies the DAO to the right jar but I get an error indicating "EJB3 failed to resolve persistence unit entities-ejb#testPU" with an underlying error being "Can't find a deployment unit named entities-ejb". However, I do see the entities-ejb jar underneath the ear folder JBOSS builds.

             

             

             

            org.jboss.deployers.spi.DeploymentException: Error deploying entities-ejb.jar: Exception while processing container metadata for EJB: JPATestDAO in unit: entities-ejb.jar

                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)

                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:61)

                at org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer.deploy(AbstractSimpleVFSRealDeployer.java:56)

                at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)

                at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)

                at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1454)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1172)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1225)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1113)

                at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

                at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

                at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)

                at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:789)

                at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:699)

                at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)

                at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)

                at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)

                at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)

                at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

                at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778)

                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543)

                at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)

                at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256)

                at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)

                at org.jboss.Main.boot(Main.java:221)

                at org.jboss.Main$1.run(Main.java:556)

                at java.lang.Thread.run(Thread.java:619)

            Caused by: java.lang.Exception: Exception while processing container metadata for EJB: JPATestDAO in unit: entities-ejb.jar

                at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:551)

                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)

                ... 35 more

            Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=myEAR.ear,jar=entities-ejb.jar,name=JPATestDAO,service=EJB3 failed to resolve persistence unit entities-ejb#testPU

                at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135)

                at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76)

                at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:629)

                at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:420)

                at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:529)

                ... 36 more

            Caused by: java.lang.IllegalArgumentException: Can't find a deployment unit named entities-ejb at AbstractVFSDeploymentContext@26398355{vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/8080_jvm/deploy/myEAR.ear/entities-ejb.jar/}

                at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.getDeploymentUnit(BasePersistenceUnitDependencyResolver.java:87)

                at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:97)

                at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:778)

                at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1514)

                at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)

                ... 40 more

             

             

            Thanks

            Kevin