Migrating Hibernate 3.x dependent code from JBoss 5.1.0GA to JBoss 7.1.1
madchedar0 Jun 6, 2012 3:57 PMAs suggested by Wolf-Dieter in this thread https://community.jboss.org/message/740234#740234 I'm posting my question here.
I have services which I'm migrating from the JBoss 5.1.0GA ecosystem to JBoss 7.1.1
Some of the more "complex" services depend on Hibernate in order to function. It seems that some of the Hibernate 3.x classes don't exist in Hibernate 4.x? (JBoss 7.1.1 ships with 4.1 I believe).
Does Hibernate 4.1 have support for org.hibernate.criterion.* like Hibernate 3.x did?
Here's what my services generally look like:
import org.hibernate.Session; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import javax.ejb.Startup; import javax.ejb.Singleton; @Singleton @Startup public class SomeServiceManager implements Serializable, SomeServiceManagerMBean { // ... methods that use org.hibernate.criterion classes... }
Unless I include hibernate3.jar (from Hibernate 3.x) in my application's .ear (nexus.ear), I get the following error :
13:41:25,378 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016008: Starting weld service for deployment nexus.ear
13:41:25,386 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-15) MSC00001: Failed to start service jboss.deployment.subunit."nexus.ear"."nexus.sar".INSTALL: org.jboss.msc.service.StartExcepti
on in service jboss.deployment.subunit."nexus.ear"."nexus.sar".INSTALL: Failed to process phase INSTALL of subdeployment "nexus.sar" of deployment "nexus.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
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]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_30]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_30]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_30]
Caused by: java.lang.RuntimeException: Error getting reflective information for class com.SomeServiceManager with ClassLoader ModuleClassLoader for Module "deployment.nexus.ear:main" f
rom Service Module Loader
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.service.ReflectionUtils.getClassHierarchy(ReflectionUtils.java:124)
at org.jboss.as.service.ParsedServiceDeploymentProcessor.addServices(ParsedServiceDeploymentProcessor.java:108)
at org.jboss.as.service.ParsedServiceDeploymentProcessor.deploy(ParsedServiceDeploymentProcessor.java:99)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion
at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.6.0_30]
at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [rt.jar:1.6.0_30]
at java.lang.Class.getDeclaredFields(Class.java:1743) [rt.jar:1.6.0_30]
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 9 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.criterion.Criterion from [Module "deployment.nexus.ear:main" from Service Module Loader]
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.performLoadClassChecked(ConcurrentClassLoader.java:423) [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]
... 14 more
Besides including hibernate3.jar in my .ear to avoid this error... is there a better way? What's the right way to do this in JBoss 7.1.1? Are there equivalent classes for criterion.Order and criterion.Restrictions in Hibernate 4.1?
Thanks