3 Replies Latest reply on Nov 16, 2011 10:24 PM by Dmitriy Fot

    JPA Entities not found after migrating to AS 7

    Dmitriy Fot Newbie

      Hi,

       

      I need to migrate a relatively big enterprise app from JBoss AS 4 to JBoss AS 7.

      The latest problem I encountered and was not able to resolve myself is related to persistence.xml and how the jar files scanned for JPA Entities.

       

      I have an exploaded deployment.

       

      App.ear

      - defaultEjb.jar

      ---- META-INF

      --------persistence.xml             

      - AEjb.jar

      - BEjb.jar

       

      All of the EJB jars contain the entities referenced from the persitence.xml. The whole application uses just one persistent unit.

       

      <persistence-unit name="my-unit">

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

      <jar-file>../App.ear/AEjb.jar</jar-file>

      <jar-file>../App.ear/BEjb.jar</jar-file>

      ....

       

      in the log I see that the names of the scanned jars are correct, nevetheless I get the following exception:

       

      jboss.persistenceunit."App.ear/defaultEjb.jar#my-unit": org.jboss.msc.service.StartException in service jboss.persistenceunit."App.ear/defaultEjb.jar#my-unit": Failed to start service

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

          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [:1.7.0]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.7.0]

          at java.lang.Thread.run(Unknown Source) [:1.7.0]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: my-unit] Unable to build EntityManagerFactory

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:908)

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)

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

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

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

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)

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

          ... 3 more

      Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.default.ejb.A.user references an unknown entity: com.a.ejb.UserBean

          at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:108)

          at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1501)

          at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1424)

          at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1342)

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1711)

          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)

          at org.hibern