5 Replies Latest reply on Jan 12, 2012 4:49 AM by pawcyk

    [AS7] Problem with entity mapping during deployment using jar-file in persistence.xml

    pawcyk

      Hi,

       

      I'm trying to migrate an EE application from AS5.1 to AS7.0.2.Final and I'm having a problem with entity scanning/mapping form jar file.

      My application is bundled as an EAR with structure:

      ivsHW_EAR

      |

      |----ivsHW_EJB.jar

      |----ivsHW_WAR.war

      |----icsDatabaseStructore.jar

       

      The ivsHW_EJB.jar contains persistence.xml that references entities in icsDatabaseStructore.jar (jar-file entry in persistence.xml) but during deployment the entities aren't mapped to database structure. (packages are visible but entites not)

       

      When I move persistence.xml from ivsHW_EJB.jar to icsDatabaseStructore.jar everything is mapped correctly.

      It seams that there is still problem with entity scanning using "jar-file" in persistence.xml if persistence.xml is in different jar.

       

      Here are two logs:

      1) When persistence.xml is in ivsHW_EJB.jar and database isn't created (with TRACE on JPA and org.hibernate.ejb) http://pastebin.com/UjmQH3uU

      2) When persistence.xml is in icsDatabaseStructore.jar and everything is OK  http://pastebin.com/7ANTYm8B

       

      I'm also setuping hibernate 3 and having this same problem. (Even on last nightly build of AS7)

       

      My persistence.xml

       

          <persistence-unit name="ejb33" transaction-type="JTA">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>java:jboss/datasources/IVS_HW</jta-data-source>
              <jar-file>icsDataBaseStructure-0.0.1-SNAPSHOT.jar</jar-file>
              
              <properties>
                  <!-- <property name="jboss.as.jpa.providerModule" value="org.hibernate:3"/> -->
                  <property name="hibernate.dialect" value="org.hibernatespatial.postgis.PostgisDialect" />
                  <property name="hibernate.hbm2ddl.auto" value="update"/>
              </properties>
          </persistence-unit>
      

       

      Thanks in advance

        • 1. Re: [AS7] Problem with entity mapping during deployment using jar-file in persistence.xml
          smarlow

          What happens if you put icsDatabaseStructore.jar into your ear/lib folder (I think the jar-file reference would also change to "lib/icsDataBaseStructure-0.0.1-SNAPSHOT.jar")?  Can your ivsHW_EJB.jar then see the entity classes?

          • 2. Re: [AS7] Problem with entity mapping during deployment using jar-file in persistence.xml
            pawcyk

            Unfortunately not... this same problem after moving icsDataBaseStructure-0.0.1-SNAPSHOT.jar to ear/lib directory.

            (Only packages are visible)

            http://pastebin.com/iKdPCebb

            • 3. Re: [AS7] Problem with entity mapping during deployment using jar-file in persistence.xml
              smarlow

              Can you create a unit test for this?  Probably starting with the current one here https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jpa/jarfile/JpaJarFileTestCase.java.  Also check to see what is different between your ear and JPAJarFileTestCase.

               

              General instructions for building AS7 are here.  Write back if you have trouble.  Also write back, once you have recreated the issue in a unit test.

               

              Scott

              • 4. Re: [AS7] Problem with entity mapping during deployment using jar-file in persistence.xml
                smarlow

                Also, you might also try enabling TRACE logging for org.jboss.as.jpa.  Some instructions for enabling TRACE for JPA (or any specific target) are here.

                 

                Here are some of the entity scanning TRACE log messages that are of interest.

                 

                0.  "adding '%s' to annotation index map"

                 

                1.  "getClassesInJar url=%s annotations=%s"

                 

                2.  "No classes to scan for annotations in jar '%s' (jars with classes '%s')"

                 

                3.  "getClassesInJar found class %s with annotation %s"

                From the above trace messages, you will get some information as to why the entity classes aren't being found.

                 

                Post back here what you find.

                 

                Scott

                • 5. Re: [AS7] Problem with entity mapping during deployment using jar-file in persistence.xml
                  pawcyk

                  I have problem with building AS7.

                  [INFO] JBoss Application Server: Arquillian Common ....... SUCCESS [7.425s]
                  [INFO] JBoss Application Server: Arquillian Protocol JMX . SUCCESS [6.269s]
                  [INFO] JBoss Application Server: Arquillian Managed Container  FAILURE [1:15.138s]
                  [INFO] JBoss Application Server: Arquillian Remote Container  SKIPPED
                  [INFO] JBoss Application Server: Arquillian TestNG Integration  SKIPPED
                  
                  

                  It stop build on Arquillian Managed Container tests:

                  -------------------------------------------------------
                   T E S T S
                  -------------------------------------------------------
                  Forking command line: /bin/sh -c cd /opt/jboss-as/arquillian/container-managed && /opt/sun-jdk-1.6.0.29/jre/bin/java -jar /opt/jboss-as/arquillian/container-managed/target/surefire/surefirebooter1451506914025761381.jar /opt/jboss-as/arquillian/container-managed/target/surefire/surefire4562649437214461632tmp /opt/jboss-as/arquillian/container-managed/target/surefire/surefire763432821862937573tmp
                  Running org.jboss.as.arquillian.container.managed.ManagedAsClientEnterpriseArchiveServletTestCase
                  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 68.244 sec <<< FAILURE!
                  Running org.jboss.as.arquillian.container.managed.IntegrationTestCase
                  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.044 sec <<< FAILURE!
                  Running org.jboss.as.arquillian.container.managed.ManagedInContainerTestCase
                  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.014 sec <<< FAILURE!
                  Running org.jboss.as.arquillian.container.managed.ManagedAsClientWebArchiveServletTestCase
                  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.01 sec <<< FAILURE!
                  Running org.jboss.as.arquillian.container.managed.ManagedAsClientTestCase
                  Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.005 sec
                  

                   

                  Here are reports from test that don't pass:

                  http://pastebin.com/iC4TXUqQ

                  http://pastebin.com/PBCVjhsR

                   

                  Is it normal or I'm doing something wrong?

                  Is it possible to run JpaJarFileTestCase.java without build of all JBossAS?