Using plain JPA/Hibernate4 in AS 7 cannot find entities
lostiniceland Mar 19, 2012 6:02 AMHello
I have a little demo-project and I am trying to use JPA withing AS7. I am not trying to use Hibernate 3 or any special dependecies, just the modules that the server uses by default.
When I try to deploy my WAR then I am getting a ClassNotFoundException telling me that my domain-classes cannot be found. I read the article about ClassLoading and for a war-deployment every jar within the lib-folder is added to the classpath. I checked my war-file (produced by maven) and all dependencies are available.
10:45:00,079 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.persistenceunit."bikeviewer-backend-1
.0-SNAPSHOT.jar#bikeviewer": org.jboss.msc.service.StartException in service jboss.persistenceunit."bikeviewer-backend-1.0-SNAPSHOT.jar#bikeviewer": F
ailed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: bikeviewer] class or package not found
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1400)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1183)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1047)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:692)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: java.lang.ClassNotFoundException: bikeviewer.domainmodel.impl.Bike from [Module "org.hibernate:main" from local module loader @68f1e723 (ro
ots: C:\Server\jboss-as\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_03]
at java.lang.Class.forName(Class.java:264) [rt.jar:1.7.0_03]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)
at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1317)
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1389)
... 11 more
What I found strange is the fact that when I remove the @PersistenceContext(name="bikeviewer) annotation I dont get this error (but my application doesnt work) even though I provide a persistence.xml which also maps this particular class.
It shouldnt be necessary to provide the proprietary depencies-section in the manifest since I want to use the default hibernate-module...or am I wrong here?