1 2 Previous Next 17 Replies Latest reply on Aug 11, 2011 11:41 AM by prasad.deshpande

    PersistenceUnit  Jboss7

    quynhbt

      Hello,

       

      My application run fine in Jboss4.2 with Seam2.2. I'am trying to upgrade to Jboss7 as following this document: https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7#HowdoImigratemyapplicationfromAS5orAS6toAS7-JBossLogging.

       

      Structure of my application:

       

      atlasnet.ear

      + META-INF

           + application.xml

           + jboss-deployement-structure.xml

      + lib

           + hibernate-annotations.jar

           + hibernate-core.jar

           + hibernate-common-annotations.jar

           + hibernate-entitymanagement.jar

           + hibernate-validator.jar

            ......

      + atlasnet.jar

      + atlasnet.war

       

      I have this error :

       

        

      15:31:56,617 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-7) HHH00204:Processing PersistenceUnitInfo [

      name: atlasnet_pu

      ...]

      15:31:56,618 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.persistenceunit."atlasnet.ear/atlasnet.jar#atlasnet_pu": org.jboss.msc.service.StartException in service jboss.persistenceunit."atlasnet.ear/atlasnet.jar#atlasnet_pu": Failed to start service

      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786)

      at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]

      at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]

      Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/content/lib/atlasnet-domain.jar

      at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:844)

      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:580)

      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)

      at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:168)

      at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:80)

      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

      ... 4 more

      Caused by: java.lang.RuntimeException: Missing annotation index to scan entity classes

      at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getClassesInJar(HibernateAnnotationScanner.java:123)

      at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:474)

      at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:841)

      ... 9 more

      15:31:56,958 INFO [org.jboss.seam.init.Initialization] (MSC service thread 1-10) reading /WEB-INF/components.xml

       

       

      My file persistence.xml looks like this:

       

      <?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 -->

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

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

              <jta-data-source>atlasnetDatasource</jta-data-source>

              <jar-file>/lib/atlasnet-domain.jar</jar-file>

              <properties>

                  <!-- Debugging -->

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

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

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

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

                 

                  <!-- Transaction -->

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

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

      .....

       

      any ideas would be appreciated

      Help me please

      TBQ

       

       

        • 1. Re: PersistenceUnit  Jboss7
          prasad.deshpande

          How is your datasource defined in standalone.xml/domain.xml? Also, in your persistence.xml you'll need to refer it according to rules specified in https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-JNDIPortableJNDISyntax  "JNDI Namespace Rules" section. Also, could you please attache your server.logs with this thread?

          • 2. Re: PersistenceUnit  Jboss7
            quynhbt

            Thanks for your response.

             

            Here is my datasource defined in standalone.xml

             

            <datasource jndi-name="atlasnetDatasource" pool-name="atlasnetDatasource" enabled="true" jta="true" use-java-context="true" use-ccm="true">

                                <connection-url>

                                    jdbc:edbc://dsd.dsdev.in:II7/atd_head;CURSOR=READONLY

                                </connection-url>

                                <driver>

                                    edbc.jar

                                </driver>

                                <pool>

                                    <prefill>

                                        false

                                    </prefill>

                                    <use-strict-min>

                                        false

                                    </use-strict-min>

                                    <flush-strategy>

                                        FailingConnectionOnly

                                    </flush-strategy>

                                </pool>

                                <security>

                                    <user-name>

                                        tb

                                    </user-name>

                                    <password>

                                        lecourbe

                                    </password>

                                </security>

                                <validation>

                                    <validate-on-match>

                                        false

                                    </validate-on-match>

                                    <background-validation>

                                        false

                                    </background-validation>

                                    <useFastFail>

                                        false

                                    </useFastFail>

                                </validation>

                            </datasource>

                            <drivers>

                                <driver name="edbc.jar" module="ca.edbc">

                                    <driver-class>

                                        ca.edbc.jdbc.EdbcDriver

                                    </driver-class>

                                </driver>

                            </drivers>

             

            The file server.log is in attach

             

            TQB

            • 3. Re: PersistenceUnit  Jboss7
              prasad.deshpande

              Your logs doesn't show from the begining, it would be helpful to see what name datasource is bound to in logs. As per your configuration, It should be bound to "java:jboss/datasources/atlasnetDatasource", so try <jta-data-source>java:jboss/datasources/atlasnetDatasource</jta-data-source> in persistence.xml. Also, just to be sure, try putting "java:jboss/datasources/atlasnetDatasource" in the jndi-name of your datasource definition.

              • 4. Re: PersistenceUnit  Jboss7
                quynhbt

                I changed the name of datasource to java:jboss/datasources/atlasnetDatasource

                 

                but I have the same error.

                 

                In attach are the files server.log, standalone.xml and persistence.xml

                 

                Thanks

                 

                TQB

                • 5. Re: PersistenceUnit  Jboss7
                  prasad.deshpande

                  Hmm.. loking at your logs, it's trying to scan <jar-file>../lib/atlasnet-domain.jar</jar-file>, If your persistence.xml is in atlasnet.jar, then I think your path should be relative to atlasnet.jar, so shouldn't it be <jar-file>lib/atlasnet-domain.jar</jar-file> ? Could you please check that?

                   

                  If your persistence.xml is in atlasnet.jar, does atlasnet.jar also has classes with @Entity annotation? If not, & if only lib/atlasnet-domain.jar contains classes with @Entity annotation, then try moving your persistence.xml to META-INF of lib/atlasnet-domain.jar. That should work too.

                  • 6. Re: PersistenceUnit  Jboss7
                    quynhbt

                    The atlasnet-domain.jar is in atlasnet.war/lib.

                     

                    Atlasnet.jar has not classes with @Entity annotation, Only lib/atlasnet-domain.jar contains classes with @Entity annotation.

                     

                    I moved the persistence.xml to atlasnet.war/META-INF and it has no longer this error. But it has another one :

                     

                     

                    18:06:05,624 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 2) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => "Operation handler failed to complete"}}

                    The file server.log is in attach

                    Best regards

                    TQB

                    • 7. Re: PersistenceUnit  Jboss7
                      quynhbt

                      Today, I restarted AS 7, and it has always the same error, although I put the file persistence.xml in the atlasnet.ear/META-INF.

                        

                        

                       

                      09:28:10,229 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-16) MSC00001: Failed to start service jboss.persistenceunit."atlasnet.ear#atlasnet_pu": org.jboss.msc.service.StartException in service jboss.persistenceunit."atlasnet.ear#atlasnet_pu": Failed to start service

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786)

                      at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]

                      at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]

                      Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/lib/atlasnet-domain.jar

                      at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:844)

                      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:580)

                      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)

                      at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:168)

                      at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:80)

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

                      ... 4 more

                      Caused by: java.lang.RuntimeException: Missing annotation index to scan entity classes

                      at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getClassesInJar(HibernateAnnotationScanner.java:123)

                      at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:474)

                      at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:841)

                      ... 9 more

                        

                        

                      The structure of my application now :

                        

                        

                      atlasnet.ear

                      + META-INF

                        

                           + application.xml

                        

                           + jboss-deployement-structure.xml

                           + persistence.xml

                      + lib

                        

                           + atlasnet-domain.jar

                           + hibernate-core.jar

                           + hibernate-annotations.jar

                           + hibernate-commons-annotaions.jar

                           + hibernate-validator.jar

                           + hibernate-entitymanager.jar

                           ...

                      + atlasnet.jar

                        

                      + atlasnet.war

                      + jboss-seam.jar

                        

                      This is an error of the relative path of <jar-file>  ??? It can not find the jar file.

                       

                      Best regards

                       

                      TQB

                        

                        

                      • 8. Re: PersistenceUnit  Jboss7
                        prasad.deshpande

                        location of pesistence.xml should not be in ear/META-INF, see https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-Deployment

                         

                        If you say your @Entity classes are in atlasnet.war & if you only need to refer it from WAR file then you can put persistence.xml in atlasnet.war/WEB-INF/lib/atlasnet-domain.jar/META-INF. But if either of your EJB-jar needs @Entity classes, then consider moving atlasnet-domain.jar (persistence.xml should still be in the atlasnet-domain.jar) to ear/lib folder.

                         

                        If this still doesn't work, is it possible for you to attach your application that reproduces this issue?

                        1 of 1 people found this helpful
                        • 9. Re: PersistenceUnit  Jboss7
                          quynhbt

                          Thank you very much, Prasad Deshpande

                           

                          I put the persistence.xml file in atlasnet-domain.jar/META-INF:

                           

                          atlasnet.ear

                          + META-INF

                               + application.xml

                               + jboss-deployement-structure.xml

                          + lib

                               + atlasnet-domain.jar

                                     + META-INF

                                          + ejb-jar.xml

                                          + persistence.xml

                               + hibernate-annotations.jar

                               + hibernate-core.jar

                               + hibernate-common-annotations.jar

                               + hibernate-entitymanagement.jar

                               + hibernate-validator.jar

                                ......

                          + atlasnet.jar

                          + atlasnet.war

                           

                          I has no longer the error of <jar-file> but this error :

                           

                          12:13:02,246 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC00001: Failed to start service jboss.persistenceunit."atlasnet.ear#atlasnet_pu": org.jboss.msc.service.StartException in service jboss.persistenceunit."atlasnet.ear#atlasnet_pu": Failed to start service

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786)

                          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]

                          at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]

                          Caused by: java.lang.AbstractMethodError: ca.edbc.jdbc.EdbcMetaData.supportsGetGeneratedKeys()Z

                          at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl

                          Do you have any idea ??

                          Thanks

                          Best regards

                           

                          TQB

                          • 10. Re: PersistenceUnit  Jboss7
                            prasad.deshpande

                            Seems to me that something to do with your JDBC driver probably. How have you deployed your datasource? It looks to me that you have put your jdbc.jar in deployments folder, but in your datasource definition in post abve you are referring it as a module module="ca.edbc". How exactly your jdbc driver installed?

                             

                            Can you check installing your jdbc driver as  module http://community.jboss.org/wiki/DataSourceConfigurationInAS7. If you get the same error?

                            • 11. Re: PersistenceUnit  Jboss7
                              quynhbt

                              I installed my jdbc driver as a module or as a deployment, i get the same error.

                               

                              I used the admin console to check it.  Everything looked fine, I found that it is enable.

                               

                              module.xml :

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

                              <module xmlns="urn:jboss:module:1.0" name="ca.edbc">
                                <resources>
                                  <resource-root path="edbc.jar"/>
                                      <!-- Insert resources here -->
                                </resources>
                                <dependencies>
                                  <module name="javax.api"/>
                                  <module name="javax.transaction.api"/>
                                </dependencies>
                              </module>

                               

                              datasource in standalone-preview.xml :

                               

                              <subsystem xmlns="urn:jboss:domain:datasources:1.0">
                                          <datasources>
                                              <datasource jndi-name="java:jboss/datasources/atlasnetDatasource" pool-name="atlasnetDatasource" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                                                  <connection-url>
                                                      jdbc:edbc://dsd.dsdev.in:II7/atd_head;CURSOR=READONLY
                                                  </connection-url>
                                                  <driver>
                                                      edbc.jar
                                                  </driver>
                                                  <pool>
                                                      <prefill>
                                                          false
                                                      </prefill>
                                                      <use-strict-min>
                                                          false
                                                      </use-strict-min>
                                                      <flush-strategy>
                                                          FailingConnectionOnly
                                                      </flush-strategy>
                                                  </pool>
                                                  <security>
                                                      <user-name>
                                                          tb
                                                      </user-name>
                                                      <password>
                                                          lecourbe
                                                      </password>
                                                  </security>
                                                  <validation>
                                                      <validate-on-match>
                                                          false
                                                      </validate-on-match>
                                                      <background-validation>
                                                          false
                                                      </background-validation>
                                                      <useFastFail>
                                                          false
                                                      </useFastFail>
                                                  </validation>
                                              </datasource>
                                              <drivers>
                                                  <driver name="edbc.jar" module="ca.edbc">
                                                      <driver-class>
                                                          ca.edbc.jdbc.EdbcDriver
                                                      </driver-class>
                                                  </driver>
                                              </drivers>
                                          </datasources>
                                      </subsystem>

                               

                               

                              Best regards

                              TQB

                              • 12. Re: PersistenceUnit  Jboss7
                                prasad.deshpande

                                Can you attach a sample application that would reproduce this error? Otherwise try narrowing down to find whether error is due to just JDBC or related to application packaging/deployment.

                                • 13. Re: PersistenceUnit  Jboss7
                                  smarlow

                                  Can you try a version of the JDBC driver that supports DatabaseMetaData.supportsGetGeneratedKeys?  That seems to be missing.

                                  • 14. Re: PersistenceUnit  Jboss7
                                    smarlow

                                    Others will be interested in whether you can proceed with a new driver or not (if not, please explain why which could help others).  Currently, you are getting a "AbstractMethodError: ca.edbc.jdbc.EdbcMetaData.supportsGetGeneratedKeys()Z" because the edbc JDBC driver doesn't support the DatabaseMetaData.supportsGetGeneratedKeys method call. 

                                    1 2 Previous Next