4 Replies Latest reply on Sep 22, 2011 2:11 AM by catares

    Deployment ordering of jar-files within ear

    catares

      Hello,

       

      I'm using Jboss AS 6.1 an have a problem with the deployment-order of my jar's.

       

      My situation: I have one jar (beans.jar) which has all the EJB3 entities and the persistence.xml file an client-jar (emwextension.jar)

       

      The Annotaion

      @PersistenceContext(unitName = "edesk")

          public EntityManager em;

       

      in Stateless beans inside the EJB3 jar works fine, but when I try to add

       

      @PersistenceContext(unitName="xcore")
          private EntityManager em;

       

      to the client jar, it keeps saying:

       

       

      12:04:32,953 ERROR [AbstractKernelController] Error installing to Real: name=vfs:///opt/jboss-6.1.0.Final/server/edesk/deploy/edesk4postgres.ear state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error deploying emwextension.jar: Exception while processing container metadata for EJB: StatisticsDAOEjb3Impl in unit: emwextension.jar
          at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:194) [:6.1.0.Final]
          at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:60) [:6.1.0.Final]
          at org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer.deploy(AbstractSimpleVFSRealDeployer.java:56) [:2.2.2.GA]
          at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:63) [:2.2.2.GA]
          at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.2.GA]
          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.2.GA]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.2.GA]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.2.GA]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1603) [:2.2.2.GA]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.2.GA]
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.2.GA]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.2.GA]
          at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.2.GA]
          at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.1.0.Final]
          at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
          at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]
          at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.SP2]
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
          at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
          at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
          at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
          at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
          at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2]
          at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2]
          at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2]
          at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.1.0.Final]
          at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.1.0.Final]
          at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6]
          at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6]
          at java.lang.Thread.run(Thread.java:636) [:1.6.0_20]
      Caused by: java.lang.Exception: Exception while processing container metadata for EJB: StatisticsDAOEjb3Impl in unit: emwextension.jar
          at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:561) [:1.7.21]
          at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:177) [:6.1.0.Final]
          ... 49 more
      Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=edesk4postgres.ear,jar=emwextension.jar,name=StatisticsDAOEjb3Impl,service=EJB3 failed to resolve persistence unit edesk
          at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135) [:1.7.21]
          at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76) [:1.7.21]
          at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:779) [:1.7.21]
          at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:471) [:1.7.21]
          at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:553) [:1.7.21]
          ... 50 more
      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'edesk' in AbstractVFSDeploymentContext@153299083{vfs:///opt/jboss-6.1.0.Final/server/edesk/deploy/edesk4postgres.ear/emwextension.jar/}
          at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-4]
          at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:817) [:1.7.21]
          at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1689) [:1.7.21]
          at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130) [:1.7.21]
          ... 54 more
      

        

      The server want to deploy the client-jar emwextension.jar bevor the beans.jar ist deployed. The server can'nt find the the persistence unit named 'edesk' because this persistence unit is defined in the persistence.xml from the beans.jar.

       

      How can I define the order to deploy the jar from my ear-file???

       

      Please help soon as possible!!!!!!

       

      Thanks for all answers.

        • 1. Re: Deployment ordering of jar-files within ear
          mp911de

          Hi Carmen,

          usually JBoss determines itself the deployment order. You could add for your case a @Depends Annotation on your EJB, which is outside the PersistenceContext-Jar. The @Depends works the same way as used within the JBoss XML-Files, you just specify the MBean on which the EJB Deployment depends.

          You can also checkout http://lists.jboss.org/pipermail/jboss-user/2007-June/062935.html which would have some JBoss modifications as consequence.

           

          Best regards,

          Mark

          1 of 1 people found this helpful
          • 2. Re: Deployment ordering of jar-files within ear
            catares

            hello Mark,

             

            I tryed the @Depends-Annotation, but I have stil the same error at the stacktrace.

             

            The @Depends-Annotation works fine when I have some jar-file in the same Ecplise-Project. But when I have an other Eclipse-Project with a jar-File, which should wait until the jar-File of the first Eclipse-Project are deployed.

             

            My structure:

             

            projectA:

               - src

                  - - mypackage

                       - - - FbmsService.java (here is: @Depends("eDesk:service=ConversionJobService"))

                       - - - PrijectDAOEjb3Impl.java (here is: @PersistenceContext(unitName="../beans.jar#edesk")

               - target

                   - - fbmsextension-jar

                          - - - jboss-service.xml

             

            projectB:

              - src

              - target

                  - - beans.jar

                        - - - jboss-service.xml

                        - - - persistence.xml (here is the persistence unit defined: <persistence-unit name="edesk">)

             

             

            The fbmsextension.jar should uses the persistence unit of the beans.jar. But this does not work!!!

            • 3. Re: Deployment ordering of jar-files within ear
              mp911de

              Hi Carmen,

              it turns out, that your behavior is according to the JPA spec. It's defined, that:

              If a persistence unit is defined in an EJB-JAR file it is not visible to other deployed jars using the @PersistenceContext or @PersistenceUnit annotation. This scoping is required by the specification.

               

              See http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/entityconfig.html, Section 3.4.1

               

              But you could bind the PersistenceContext to JNDI and do a lookup on @PostCreate

               

              Best regards,

              Mark

              • 4. Re: Deployment ordering of jar-files within ear
                catares

                Hello Mark,

                 

                thanks for your help!

                 

                I have solved my problem now. I changed the LegacyDeploymentContextComparator in the conf/bottstrap/deployers.xml to LegacyPrefixDeploymentContextComparator an give all my Jars a numbers as prefix. So I can controll the order of deploying them.

                (https://issues.jboss.org/browse/JBPAPP-4209)

                 

                 

                It works fine. Thanks