2 Replies Latest reply on Mar 9, 2011 5:13 AM by jan piel

    Persistence Unit and multiple ejb jars in JBOSS 5.1

    K Thapa Newbie

      Hello,

      Currently we have a JBOSS 4.3 application with two ejb jars:dbEJB3.jar and messagingEJB3.jar. The first one is responsible for database persistence and has persistence.xml under META-INF. We have the persistence defiend as 'myPU' . The latter jar is responsible purely for jms interaction which does not require PU information. So, no direct reference to any of the DAOs from dbEJB3.jar. It does references other ejb's from dbEJB3.jar which in turn reference DAOs

       

      When we  try to upgrade our app to JBOSS 5.1, we see that the application fails to deploy because the messagingEJB3.jar now looks for 'myPU' even though it does not need DAOs. It cannot find the PU information because we have not added the persistence xml in its META-INF.

       

      Why is it even looking for 'myPU' in the first place? Even more surprising is the first line in the error message

      16:22:26,687 ERROR [Ejb3Deployment] Exception while processing container metadata for EJB: JPAMyDAO in unit: messagingEJB3.jar

       

      JPAMyDAO is not defined in messagingEJB3.jar but it is defined in dbEJB3.jar instead. There isn't a reference of this DAO in messagingEJB3.jar at all.

       

      Any insights will be much appreciated.

       

      Thanks

       

      Complete Error stack trace is:

       

       

      16:22:26,687 ERROR [Ejb3Deployment] Exception while processing container metadata for EJB: JPAMyDAO in unit: messagingEJB3.jar

      16:22:26,687 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/myapp_8080_jvm/deploy/myEAR.ear/ state=PreReal mode=Manual requiredState=Real

      org.jboss.deployers.spi.DeploymentException: Error deploying messagingEJB3.jar: Exception while processing container metadata for EJB: JPAMyDAO in unit: messagingEJB3.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: JPAMyDAO in unit: messagingEJB3.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=messagingEJB3.jar,name=JPAMyDAO,service=EJB3 failed to resolve persistence unit myPU

          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 'myPU' in AbstractVFSDeploymentContext@23764234{vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/myapp_8080_jvm/deploy/myEAR.ear/messagingEJB3.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

      16:22:26,734 INFO  [ProfileServiceBootstrap] Loading profile: ProfileKey@91e143[domain=default, server=default, name=myapp_8080_jvm]

      16:22:26,734 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

       

      DEPLOYMENTS IN ERROR:

        Deployment "vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/myapp_8080_jvm/deploy/myEAR.ear/" is in error due to the following reason(s): java.lang.IllegalArgumentException: Can't find a persistence unit named 'myPU' in AbstractVFSDeploymentContext@23764234{vfsfile:/C:/JBossDevStudio_3.0.1/jboss-eap/jboss-eap-5.1/server/myapp_8080_jvm/deploy/myEAR.ear/messagingEJB3.jar/}