7 Replies Latest reply on Feb 23, 2011 11:27 AM by ramsnaps

    upgrading to JBoss 5.1.0.GA: Can't find a persistence unit

    asookazian

      Upon deployment in AS 5.1.0.GA,  I see the following exception at the end of the deployment output to server.log:

       

      {code}Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'reports-persistence-unit' in AbstractVFSDeploymentContext@1391609498{vfszip:/opt/jboss-5.1.0.GA/server/all/deploy/com.echo.reports.ear-1.6.0-SNAPSHOT.ear/com.echo.billing.services.reports-1.6.0-SNAPSHOT.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)

              ... 41 more{code}

       

      I've seen some other threads on this but mine is not 'null'.  Any idea why this is happening and how to fix?  Works fine with 4.2.2.GA.  There is no persistence.xml in the META-INF directory of that JAR specified above.  How does Jboss know to scan that particular JAR?  It does not have any persistence related classes in that JAR.  thx.

        • 1. upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
          asookazian

          Here is the entire stack trace.  Please note that ReportsAgentDataReaderBean is not actually in com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar, it's actually in com.echo.billing.reports.services.persistence-1.6.0-SNAPSHOT.jar.  In the META-INF for the latter JAR, there are the following files: MANIFEST.MF, ejb-jar.xml, persistence.xml (and most likely a superfluous maven directory).  In the com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar\META-INF directory, there is only a MANIFEST.MF and maven directory.

           

          2011-02-08 11:25:18,519 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Real: name=vfszip:/opt/jboss-5.1.0.GA/server/all/deploy/com.echo.reports.ear-1.6.0-SNAPSHOT.ear/ state=PreReal mode=Manual requiredState=Real

          org.jboss.deployers.spi.DeploymentException: Error deploying com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar: Exception while processing container metadata for EJB: ReportsAgentDataReaderBean in unit: com.echo.billing.services.reports-1.6.0-SNAPSHOT.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.doInstallParentFirst(DeployersImpl.java:1210)

                  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(Unknown Source)

          Caused by: java.lang.Exception: Exception while processing container metadata for EJB: ReportsAgentDataReaderBean in unit: com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar

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

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

                  ... 34 more

          Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=com.echo.reports.ear-1.6.0-SNAPSHOT.ear,jar=com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar,name=ReportsAgentDataReaderBean,service=EJB3 failed to resolve persistence unit reports-persistence-unit

                  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:590)

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

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

                  ... 35 more

          Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'reports-persistence-unit' in AbstractVFSDeploymentContext@1391609498{vfszip:/opt/jboss-5.1.0.GA/server/all/deploy/com.echo.reports.ear-1.6.0-SNAPSHOT.ear/com.echo.billing.services.reports-1.6.0-SNAPSHOT.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)

                  ... 41 more

          2011-02-08 11:25:18,620 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

           

          DEPLOYMENTS IN ERROR:

            Deployment "vfszip:/opt/jboss-5.1.0.GA/server/all/deploy/com.echo.reports.ear-1.6.0-SNAPSHOT.ear/" is in error due to the following reason(s): java.lang.IllegalArgumentException: Can't find a persistence unit named 'reports-persistence-unit' in AbstractVFSDeploymentContext@1391609498{vfszip:/opt/jboss-5.1.0.GA/server/all/deploy/com.echo.reports.ear-1.6.0-SNAPSHOT.ear/com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar/}

           

          2011-02-08 11:25:18,628 INFO  [org.apache.coyote.http11.Http11Protocol] (main) Starting Coyote HTTP/1.1 on http-geminidev4.dev.wdh.intuit.com%2F172.19.217.144-8080

          2011-02-08 11:25:18,647 INFO  [org.apache.coyote.ajp.AjpProtocol] (main) Starting Coyote AJP/1.3 on ajp-geminidev4.dev.wdh.intuit.com%2F172.19.217.144-8009

          2011-02-08 11:25:18,654 INFO  [org.jboss.bootstrap.microcontainer.ServerImpl] (main) JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 45s:181ms

          • 2. upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
            asookazian

            Here is the persistence.xml:

             

            <?xml version="1.0" encoding="UTF-8"?>

            <persistence 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"

                version="1.0">

               

                <persistence-unit name="reports-persistence-unit" transaction-type="JTA">

                    <provider>org.hibernate.ejb.HibernatePersistence</provider>

                    <jta-data-source>java:/XAREPORTSDS</jta-data-source>

             

                    <mapping-file>META-INF/reports.orm.xml</mapping-file>

             

                    <class>com.echo.billing.reports.domain.AdnMeta</class>

                    <class>com.echo.billing.reports.domain.AdnTrans</class>

                    <class>com.echo.billing.reports.domain.AdnFeeSummary</class>

                    <class>com.echo.billing.reports.domain.AdnOtherSummary</class>

                    <class>com.echo.billing.reports.domain.AdnTransSummary</class>

                    <class>com.echo.billing.reports.domain.AdnCbSummary</class>

                    <class>com.echo.billing.reports.domain.IcpMerchantAddMeta</class>

                    <class>com.echo.billing.reports.domain.IcpIncrData</class>

                    <class>com.echo.billing.reports.domain.IcpMerchantFees</class>

                    <class>com.echo.billing.reports.domain.IcpMerchantRFeeSched</class>

                    <class>com.echo.billing.reports.domain.DbsMeta</class>

                    <class>com.echo.billing.reports.domain.DbsData</class>

                    <class>com.echo.billing.reports.domain.MaMeta</class>

                    <class>com.echo.billing.reports.domain.MaData</class>

                    <class>com.echo.billing.reports.domain.MaPayment</class>

                    <class>com.echo.billing.reports.domain.MsKey</class>

                    <class>com.echo.billing.reports.domain.MsMeta</class>

                    <class>com.echo.billing.reports.domain.MsData</class>

                    <class>com.echo.billing.reports.domain.AgentSalesData</class>

                           

                    <exclude-unlisted-classes>true</exclude-unlisted-classes>

             

                    <properties>

                            <property name="hibernate.dialect"

                                value="org.hibernate.dialect.Oracle10gDialect" />

                            <property name="hibernate.show_sql" value="false" />

                            <!-- property name="hibernate.cache.provider_class"

                                value="org.hibernate.cache.EhCacheProvider" / -->

                            <property

                                name="hibernate.transaction.manager_lookup_class"

                                value="org.hibernate.transaction.JBossTransactionManagerLookup" />

                            <property name="jboss.entity.manager.factory.jndi.name"

                                value="java:comp/reports-persistence-unit" />

                            <property name="hibernate.hbm2ddl.auto" value="create-drop" />

                    </properties>

                </persistence-unit>   

            </persistence>

            • 3. Re: upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
              asookazian

              In com.echo.billing.services.reports-1.6.0-SNAPSHOT.jar, there is a SLSB with the following injection:

               

               

              {code:java}

              @EJB

              protected ReportsAgentDataReader agentDataReader;

              {code}

              • 4. Re: upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
                asookazian

                Also, please note that the persistence.xml with the same PU in question (reports-persistence-unit) exists in two different jars in the EAR deployment.  One is com.echo.billing.reports.dao.gemini and the other is com.echo.billing.reports.services.persistence.

                 

                The question is why can't it find the PU when the EJB is injected?

                 

                Same EAR deploys fine in JBoss 4.2.2.GA, so is this a spec compliance change (JBAS 5 is 100% TCK compliant and 4.2.x is not) or a vendor-specific impl?  thx.

                • 5. Re: upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
                  asookazian

                  I added the same persistence.xml to the other jar and the exception is no longer happening.  How many times can we have the same persistence.xml in multiple JARs?  Is there a global location for this persistence.xml?

                  • 6. upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
                    jaikiran

                    Where exactly is the persistence.xml located?

                    • 7. Re: upgrading to JBoss 5.1.0.GA: Can't find a persistence unit
                      ramsnaps

                      Jaikiran,

                       

                      I had a similar issue as Arbi when we upgraded from Jboss 4.x to Jboss 5.1. We still have the issue irrespective of having persistence.xml in all the necessary jars.

                       

                       

                      Below is the description of the issue. Only Jar "A" was deployed successfully but when I try to deploy other EJB3 jars as built for Jboss 4.x, we get below errors stating that Persistent Units are already installed.

                       

                       

                       

                      DEPLOYMENTS IN ERROR:

                       

                        Deployment  "vfszip:/C:/programs/jboss/jboss-eap-5.1/jboss-as/server/default/deploy/B-ejb.jar/"  is in error due to the following reason(s): java.lang.IllegalStateException:  persistence.unit:unitName=#X-ejbPU is already installed.

                        Deployment  "vfszip:/C:/programs/jboss/jboss-eap-5.1/jboss-as/server/default/deploy/C-ejb.jar/"  is in error due to the following reason(s): java.lang.IllegalStateException:  persistence.unit:unitName=#Y-ejbPU is already installed.

                       

                       

                       

                       

                      Persistence.xmlis copied and jarred in the following 3 ejb jars.

                       

                      Jar File Path

                       

                      Contained Files

                       

                      1)     A-ejb.jar\META-INF\

                      2)     B-ejb.jar\META-INF\

                      3)     C-ejb.jar\META-INF\

                       

                      1)    MANIFEST.MF

                      2)    persistence.xml

                       

                      4)     D-ejb.jar\META-INF\

                       

                      1)    MANIFEST.MF

                       

                       

                       

                       

                      To avoid this issue, I had removed duplicate persistence.xml from other jars and just had in the A-ejb.jar as below.

                       

                       

                      Jar File Path

                       

                      Contained Files

                       

                      A-ejb.jar\META-INF\

                       

                       

                      1)    MANIFEST.MF

                      2)    persistence.xml

                       

                      B-ejb.jar\META-INF\

                       

                       

                      1)    MANIFEST.MF

                       

                       

                      B-ejb.jar\META-INF\

                       

                      1)    MANIFEST.MF

                       

                       

                      C-ejb.jar\META-INF\

                       

                      1)    MANIFEST.MF

                       

                       

                       

                      I ran into “Can't find a persistenceunit” error instead.

                       

                      DEPLOYMENTS IN ERROR:

                       

                         Deployment  "vfszip:/C:/programs/jboss/jboss-eap-5.1/jboss-as/server/default/deploy/B-ejb.jar/"  is in error due to the following reason(s):  java.lang.IllegalArgumentException: Can't find a persistence unit  named 'X-ejbPU' in AbstractVFSDeploymentContext@14820610{vfszip:/C:/programs/j

                      boss/jboss-eap-5.1/jboss-as/server/default/deploy/B-ejb.jar/}

                       

                       

                       

                      Below is the description from Jboss manual and as per this, cross referencing of Persistence Unit is not supported, but have suggested a way to use it whichalso did not work for me.

                       

                      3.4. Referencing  persistence units

                      3.4.1. Scoped deployments

                      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.

                      3.4.2. Referencing from Global JNDI

                      Persistence units are not  available within global JNDI unless you explicitly configure them to do so.  There are two properties you can specify in your persistence.xml file to  enable this. jboss.entity.manager.jndi.name gives you a transaction scoped entity manager you can interact with. jboss.entity.manager.factory.jndi.name binds the entity manager factory into  global JNDI.

                      <persistence>
                         <persistence-unit name="manager1">
                            <jta-data-source>java:/DefaultDS</jta-data-source>
                            <properties>
                               <property name="jboss.entity.manager.jndi.name" value="java:/Manager1"/>
                               <property name="jboss.entity.manager.factory.jndi.name" value="java:/Manager1Factory"/>
                            </properties>
                         </persistence-unit>
                      </persistence>
                                

                       

                       

                       

                      Persistence.xml : enabled PU’s as Global JNDI as per the Jboss  Documentation

                       

                      <?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="X-ejbPU"  transaction-type="JTA">

                           <jta-data-source>java:/DSDS-X</jta-data-source>

                             <properties>

                               <property name="jboss.entity.manager.jndi.name"  value="java:/Manager1"/>

                              <property  name="jboss.entity.manager.factory.jndi.name"  value="java:/Manager1Factory"/>

                               <property name="hibernate.dialect"  value="org.hibernate.dialect.Oracle9iDialect"/>

                               <property name="hibernate.cache.region.factory_class"  value="org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory"/>

                               <property name="hibernate.treecache.mbean.object_name"  value="jboss.cache:service=EJB3EntityTreeCache"/>

                               <property name="hibernate.cache.use_query_cache"  value="true"/>

                           </properties>

                         </persistence-unit>

                         <persistence-unit name="Y-ejbPU"  transaction-type="JTA">

                           <jta-data-source>java:/DSDS-Y</jta-data-source>

                       

                       

                                   <properties>

                               <property name="jboss.entity.manager.jndi.name"  value="java:/Manager1"/>

                              <property  name="jboss.entity.manager.factory.jndi.name"  value="java:/Manager1Factory"/>

                               <property name="hibernate.dialect"  value="org.hibernate.dialect.Oracle9iDialect"/>

                             </properties>

                         </persistence-unit> 

                        <persistence-unit  name="Z-ejbPU"  transaction-type="JTA">

                           <jta-data-source>java:/DSDS-Z</jta-data-source>

                             <properties>                

                              <property  name="jboss.entity.manager.jndi.name"  value="java:/Manager1"/>

                              <property  name="jboss.entity.manager.factory.jndi.name"  value="java:/Manager1Factory"/>

                      <property  name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>

                               <property name="hibernate.cache.region.factory_class"  value="org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory"/>

                               <property name="hibernate.treecache.mbean.object_name"  value="jboss.cache:service=EJB3EntityTreeCache"/>

                               <property name="hibernate.cache.use_query_cache"  value="true"/>

                           </properties>

                         </persistence-unit>

                      </persistence>

                       

                       

                       

                      Jaikiran, I also saw your other post related to this where you had stated this issue as being a bug with JBoss 5.1, if that was true, wonder how Arbi was able to successfully deploy with persistence.xml file duplicated in other jars.

                       

                      Below is the link to your other post.

                       

                      http://community.jboss.org/message/568982?tstart=0


                      Thanks,

                      Ram.