5 Replies Latest reply on Dec 12, 2011 3:36 PM by lukasw44

    [AS7] Share a persistence.xml file among several jar

    jsebfranck

      Hi,

       

      In a .ear file, my EJBs are copied in several jar and war for some technical constraints. And only one of these jar contains the persistence.xml file where I have configured several persistence units.

       

      myear.ear

      |---- myjar1.jar

      |-------- EjbA.class

      |-------- EjbB.class

      |-------- META-INF/persistence.xml

      |---- myjar2.jar

      |-------- EjbA.class

      |-------- EjbB.class

      |---- mywar.war

      |-------- EjbA.class

      |-------- EjbB.class

       

      The problem is Jboss cannot find the persistence configuration for the classes within the jar "myjar2" and the war :

      Could not get class configuration for ....EjbA.class due to the following errors: Can't find a deployment unit named xxxxx at subdeployment "jar2.jar" of deployment "myear.ear"

       

      To resolve that, I tried to create a new jar containing only the persistence.xml file but it doesn't work.

       

      Any idea of how I could fix that without reorganising all my jars?

        • 1. Re: [AS7] Share a persistence.xml file among several jar
          smarlow

          Could you either upload or insert a http://www.pastie.org link to the part of your server.log (in as7/standalone/logs/ folder) that contains the error.  Also show the contents of your persistence.xml.

          • 2. Re: [AS7] Share a persistence.xml file among several jar
            jsebfranck

            Thank you for your quick answer.

             

            My persistence.xml file :

             

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

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

                  <jar-file>pm-main-ejb3.jar</jar-file>

                  <properties>

                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

                  <property name="hibernate.connection.release_mode" value="after_statement"/>

                  <property name="hibernate.transaction.flush_before_completion" value="true"/>

                  <property name="hibernate.transaction.auto_close_session" value="true"/>

                  <property name="hibernate.query.factory_class" value="org.hibernate.hql.ast.ASTQueryTranslatorFactory"/>

                  <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>

                  <property name="hibernate.jdbc.batch_size" value="0"/>

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

                  <property name="hibernate.jndi.java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>

                  <property name="hibernate.jndi.java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>

                  <property name="hibernate.use_sql_comments" value="true"/>

                  </properties>

               </persistence-unit>

              

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

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

                  <properties>

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

                  </properties>

               </persistence-unit>

            </persistence>

             

            And the pastie link of the server.log : http://pastie.org/2955051

            • 3. Re: [AS7] Share a persistence.xml file among several jar
              lukasw44

              I have got the same problem with my project

              • 4. Re: [AS7] Share a persistence.xml file among several jar
                jsebfranck

                If you want your persistence.xml file to be configured for all the modules of your ear, you need to put the jar containing the file in the .ear/lib directory (JPA specification).

                 

                In my case, I create a new jar containing only the persistence.xml file and it works.

                • 5. Re: [AS7] Share a persistence.xml file among several jar
                  lukasw44

                  Iam configure my project as you say (screen with configuration)

                  And i have got err in jboss :

                   

                  1:16:09,152 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.subunit."notice.ear"."notice-ejb-1.0.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."notice.ear"."notice-ejb-1.0.jar".INSTALL: Failed to process phase INSTALL of subdeployment "notice-ejb-1.0.jar" of deployment "notice.ear"      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.6.0_20]      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.6.0_20]      at java.lang.Thread.run(Thread.java:636) [:1.6.0_20] Caused by: java.lang.RuntimeException: Could not get class configuration for notice.notice.enterprise.session.users.user.UserEntityHandlerRemote due to the following errors: Can't find a deployment unit named noticePU at subdeployment "notice-web-1.0.war" of deployment "notice.ear"      at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:130)      at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:122)      at org.jboss.as.ee.component.LazyValue.get(LazyValue.java:40)      at org.jboss.as.ee.component.EEApplicationDescription.getClassConfiguration(EEApplicationDescription.java:183)      at org.jboss.as.ejb3.component.stateless.StatelessComponentDescription.createConfiguration(StatelessComponentDescription.java:76)      at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:70)      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)      ... 5 more  21:16:09,178 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.subunit."notice.ear"."notice-web-1.0.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."notice.ear"."notice-web-1.0.war".INSTALL: Failed to process phase INSTALL of subdeployment "notice-web-1.0.war" of deployment "notice.ear"      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.6.0_20]      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.6.0_20]      at java.lang.Thread.run(Thread.java:636) [:1.6.0_20] Caused by: java.lang.RuntimeException: Could not get class configuration for notice.notice.enterprise.session.users.user.UserEntityHandlerRemote due to the following errors: Can't find a deployment unit named noticePU at subdeployment "notice-web-1.0.war" of deployment "notice.ear"      at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:130)      at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:122)      at org.jboss.as.ee.component.LazyValue.get(LazyValue.java:40)      at org.jboss.as.ee.component.EEApplicationDescription.getClassConfiguration(EEApplicationDescription.java:183)      at org.jboss.as.ejb3.component.stateless.StatelessComponentDescription.createConfiguration(StatelessComponentDescription.java:76)      at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:70)      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)      ... 5 more  21:16:09,302 INFO  [org.jboss.as.server.controller] (pool-1-thread-3) Deployment of "notice.ear" was rolled back with failure message {"Failed services" => {"jboss.deployment.subunit.\"notice.ear\".\"notice-ejb-1.0.jar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"notice.ear\".\"notice-ejb-1.0.jar\".INSTALL: Failed to process phase INSTALL of subdeployment \"notice-ejb-1.0.jar\" of deployment \"notice.ear\"","jboss.deployment.subunit.\"notice.ear\".\"notice-web-1.0.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"notice.ear\".\"notice-web-1.0.war\".INSTALL: Failed to process phase INSTALL of subdeployment \"notice-web-1.0.war\" of deployment \"notice.ear\""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.notice.\"notice-web-1.0\".ValidatorFactory missing [ jboss.naming.context.java.module.notice.\"notice-web-1.0\" ]","jboss.naming.context.java.comp.notice.\"notice-ejb-1.0\".UserEntityHandlerRemote.Validator missing [ jboss.naming.context.java.comp.notice.\"notice-ejb-1.0\".UserEntityHandlerRemote ]","jboss.naming.context.java.module.notice.\"notice-web-1.0\".Validator missing [ jboss.naming.context.java.module.notice.\"notice-web-1.0\" ]","jboss.naming.context.java.comp.notice.\"notice-ejb-1.0\".UserEntityHandlerRemote.ValidatorFactory missing [ jboss.naming.context.java.comp.notice.\"notice-ejb-1.0\".UserEntityHandlerRemote ]"]}

                   

                  ejberr.jpg

                  I an use JBoss AS 7.0.2.Final "Arc". I try define persistence xml without tag jar file, i try insert persistance.xml into META-INF folder. But its not working ..

                   

                  So whats is wrong with my configuration ?