0
votes

I am trying to migrate my project from JSF1.2, Hibernate 3.x, Jboss 4.3 to JSF 2.1, Hibernate 4.x and Jboss EAP 6.3. During startup, I get an error saying that `

10:46:35,776 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."MyEAR.ear#myJPA": org.jboss.msc.service.StartException in service jboss.persistenceunit."MyEAR.ear#myJPA": javax.persistence.PersistenceException: [PersistenceUnit: myJPA] class or package not found
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_45]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: myJPA] class or package not found
    at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1410)
    at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1193)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1057)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:702)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:75)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    ... 4 more
Caused by: java.lang.ClassNotFoundException: 
        com.xxx.persistence.Agent from [Module "org.hibernate:main" from local module loader @26a3960 (finder: local module finder @bdccedd (roots: C:\JbossEAP6.3\jboss-eap-6.3\modules,C:\JbossEAP6.3\jboss-eap-6.3\modules\system\layers\base))]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:447) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:414) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at java.lang.Class.forName0(Native Method) [rt.jar:1.6.0_45]
    at java.lang.Class.forName(Class.java:249) [rt.jar:1.6.0_45]
    at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)
    at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1327)
    at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1399)
    ... 11 more

`

My EAR structure is as below.

  • MyEAR.ear
  • MyWAR.war (persistence unit myJPA is present in web-inf/classes/meta-inf)
  • MyEJB.jar (persistence unit myJPA is present in META-INF)
  • lib/MyJPA.jar (persistence unit myJPA is present in META-INF)
  • META-INF

My jboss-deployment-structure.xml is as below. `

<jboss-deployment-structure>
    <deployment>
        <dependencies>
          <module name="deployment.MyJPA" />
        </dependencies>
        <resources>
            <resource-root path="MyJPA.jar" />
        </resources>
    </deployment>
    <sub-deployment name="MyWAR.war">
        <dependencies>
          <module name="deployment.MyEAR.ear.MyEJB.jar" />
          <module name="deployment.MyJPA" />
        </dependencies>
    </sub-deployment>
    <sub-deployment name="MyEJB.jar">
        <dependencies>
          <module name="deployment.MyJPA" />
        </dependencies>
    </sub-deployment>
    <module name="deployment.MyJPA" >
        <resources>
            <resource-root path="lib/MyJPA.jar"/>
        </resources>
    </module>
</jboss-deployment-structure>

` I am new to Jboss 7 so please let me know if my setup is not correct.

1

1 Answers

0
votes

So after lot of digging around and reading about the migration, it turns out that hibernate bundled with jboss could not read my persistence.xml properly. My persistence xml had classes written with carriage returns like below.

<class>
com.someClass
</class>

I believe the hibernate was including the newline/carriage return in the class name and hence not finding it. It was working fine in the previous hibernate 3. While I understand that my formatting was not proper, I would expect hibernate to trim and use the class names. Anyways, my issue is resolved and hopefully someone finds this helpful.