5 Replies Latest reply on Mar 25, 2010 3:55 AM by jaikiran

    2 jars in deploy, one can't find the other's PU?

    deanhiller

      PU=persistence unit

       

      I have two jars(client and a jar with all the EJB3 entities and the persistence.xml file).  I can have

       

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

       

      in Stateless beans inside the EJB3 jar just fine.  I can also inject Stateless beans that are in the EJB3 jar into the classes in the client jar as well, BUT when I try to add

       

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

       

      to the client jar, it keeps saying

       

      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'xcore' in AbstractVFSDeploymentContext@519167830{vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/}

       

      Is there something special I have to do.  We currently are in jboss5.0.1 moving to 5.1 and we have about 4 client jars(completely different applications) all on the same EJ3 jar as they share the database model beans(no reason to maintain a few different versions.  Currently, we have it working where we have to have a stateless bean injected into the client jar to make it work but I am trying to do a stateful bean with an Extended Persistence Context and I can't seem to inject the EntityManager into any class in the client jar.  Is there a way to do that?

       

      thanks,

      Dean

        • 1. Re: 2 jars in deploy, one can't find the other's PU?
          jaikiran

          The persistence unit scoping in the spec, does not allow refering persistence units across independent jar file deployments.  However, JBoss (by default, in a confiugrable way) allows this.

           

          Can you post the entire exception stacktrace and the persistence.xml file? Also please post the logs that you see on the console, when your application(s) are being deployed.

           

          null null wrote:

           


          Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'xcore' in AbstractVFSDeploymentContext@519167830{vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/}

           

          Is ata-tpv-vxml.jar the "client" jar (the one being injected with the entitymanager) that you have been mentioning in this post?

          • 2. Re: 2 jars in deploy, one can't find the other's PU?
            deanhiller

            yes, ata-tpv-vxml.jar is the client jar.  I have tried xcore3.jar#xcore and ./xcore3.jar#xcore and ../xcore3.jar#xcore and /xcore3.jar#xcore as well which all did not seem to work either.

             

            full stack trace....

             

            2010-03-23 09:44:07,521 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) N/A Error installing to Real: name=vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/ state=PreReal mode=Manual requiredState=Real
            org.jboss.deployers.spi.DeploymentException: Error deploying ata-tpv-vxml.jar: Exception while processing container metadata for EJB: AtaVxmlBeanImpl in unit: ata-tpv-vxml.jar
                    at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
                    at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
                    at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
                    at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
                    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:361)
                    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                    at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
                    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
                    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: AtaVxmlBeanImpl in unit: ata-tpv-vxml.jar
                    at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:549)
                    at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)
                    ... 33 more
            Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:jar=ata-tpv-vxml.jar,name=AtaVxmlBeanImpl,service=EJB3 failed to resolve persistence unit xcore
                    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:588)
                    at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:418)
                    at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:527)
                    ... 34 more
            Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'xcore' in AbstractVFSDeploymentContext@1438281957{vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/}
                    at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107)
                    at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:770)
                    at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1428)
                    at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)
                    ... 38 more

             

            My persistence.xml file....(xcore is the second PU not the first one)!!!

            This all works fine if I move my client code into my xcore3.jar

             

            <?xml version="1.0" encoding="UTF-8"?>
            <persistence version="1.0"
                xmlns="http://java.sun.com/xml/ns/persistence"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                <persistence-unit name="xcoreNonJta" transaction-type="RESOURCE_LOCAL">
                    <provider>org.hibernate.ejb.HibernatePersistence</provider>
                    <non-jta-data-source>java:/OracleDS</non-jta-data-source>
                    <properties>
                        <property name="hibernate.hbm2ddl.auto" value="validate" />
                        <property name="hibernate.default_schema" value="VOICELOG" />
                    
                        <property name="hibernate.dialect"
                            value="org.hibernate.dialect.Oracle10gDialect" />

             

                        <property name="hibernate.cache.provider_class"
                            value="org.hibernate.cache.HashtableCacheProvider" />
                        <property name="hibernate.transaction.manager_lookup_class"
                            value="org.hibernate.transaction.JBossTransactionManagerLookup" />
                        <!-- Binds the EntityManagerFactory to JNDI where Seam can look it up.
                            This is only relevant when the container automatically loads the persistence unit, as is the case in JBoss AS 5. -->
                        <property name="jboss.entity.manager.jndi.name" value="java:/xcoreNonJtaEntityManager"/>
                        <property name="jboss.entity.manager.factory.jndi.name" value="java:/xcoreNonJtaEntityManagerFactory" />
                       
                    </properties>
                </persistence-unit>   
                <persistence-unit name="xcore" transaction-type="JTA">
                    <jta-data-source>java:/OracleDS</jta-data-source>
                    <properties>
                        <property name="hibernate.dialect"
                            value="org.hibernate.dialect.Oracle10gDialect" />
                        <!--         <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> -->

             

                        <property name="hibernate.hbm2ddl.auto" value="validate" />
                        <property name="hibernate.default_schema" value="VOICELOG" />
                       
                        <property name="jboss.entity.manager.jndi.name" value="java:/xcoreEntityManager"/>           
                        <property name="jboss.entity.manager.factory.jndi.name" value="java:/xcoreEntityManagerFactory" />
                       
                    </properties>
                </persistence-unit>
            </persistence>

            • 3. Re: 2 jars in deploy, one can't find the other's PU?
              jaikiran

              I haven't completely looked at what you posted now (too sleepy!), but one thing you might want to check is the deployment ordering. I think the client ata-tpv-vxml.jar is being deployed before your xcore3.jar gets deployed. Try this:

               

              1) Stop the server.

              2) Place *only* xcore3.jar in the deploy and start the server

              3) If and when the server starts successfully, place the ata-tpv-vxml.jar in the deploy folder.

               

              See if that works.

              • 4. Re: 2 jars in deploy, one can't find the other's PU?
                deanhiller

                thanks!,  I tried that just now and still got an exception(and you can see from stack trace now that it was hot deployed)...

                 

                at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)

                 

                2010-03-23 14:19:32,936 ERROR [org.jboss.ejb3.Ejb3Deployment] (HDScanner) N/A Exception while processing container metadata for EJB: AtaVxmlBeanImpl in unit: ata-tpv-vxml.jar
                2010-03-23 14:19:32,938 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (HDScanner) N/A Error installing to Real: name=vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/ state=PreReal mode=Manual requiredState=Real
                org.jboss.deployers.spi.DeploymentException: Error deploying ata-tpv-vxml.jar: Exception while processing container metadata for EJB: AtaVxmlBeanImpl in unit: ata-tpv-vxml.jar
                        at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
                        at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
                        at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                        at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                        at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
                        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
                        at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
                        at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
                        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
                        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
                        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
                        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
                        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                        at java.lang.Thread.run(Thread.java:619)

                Caused by: java.lang.Exception: Exception while processing container metadata for EJB: AtaVxmlBeanImpl in unit: ata-tpv-vxml.jar
                        at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:549)
                        at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)
                        ... 28 more
                Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:jar=ata-tpv-vxml.jar,name=AtaVxmlBeanImpl,service=EJB3 failed to resolve persistence unit xcore
                        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:588)
                        at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:418)
                        at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:527)
                        ... 29 more
                Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'xcore' in AbstractVFSDeploymentContext@1907722961{vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/}
                        at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107)
                        at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:770)
                        at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1428)
                        at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)
                        ... 33 more
                2010-03-23 14:19:32,945 WARN  [org.jboss.system.server.profileservice.hotdeploy.HDScanner] (HDScanner) N/A Failed to process changes
                org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

                 

                *** DEPLOYMENTS IN ERROR: Name -> Error

                 

                vfszip:/home/jboss/jboss-5.1.0.GA-nonXA/server/all/deploy/ata-tpv-vxml.jar/ -> org.jboss.deployers.spi.DeploymentException: Error deploying ata-tpv-vxml.jar: Exception while processing container metadata for EJB: AtaVxmlBeanImpl in unit: ata-tpv-vxml.jar

                • 5. Re: 2 jars in deploy, one can't find the other's PU?
                  jaikiran

                  Dean, I had a quick look at the code which provides a JBoss specific resolvers for resolving the persistence units. And looks like accessing a persistence unit which is deployed in a standalone jar isn't currently allowed (even with the JBoss specific resolver). So in short, what you are trying to do is currently not possible. I'll have to see whether it was intentional to not allow this with the JBoss specific resolver.