Could not open Hibernate Session for transaction nested exception is java.lang.NoClassDefFoundError:

1.12K views
0

I recently upgraded the jar file from common-collections 3.2.1 to commons-collections4 4.2 because of the vulnerability in the previous version.

But after the upgrade I am seeing the exception:

ERROR :- org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ReferenceMap org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ReferenceMap at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:544) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:461) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy24.getQueueManagerNames(Unknown Source) at com.ge.portal.service.impl.QueueManagerServiceImpl.getQueueManagerNames(QueueManagerServiceImpl.java:223) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)

I am seeing this error because they have the class ReferenceMap in different package in commons-collections4 and maybe hibernate jars are not able to resolve the actual path.

My question what version of hibernate should I use now?

Below are the hibernate jars that I am using in my application:

compile “org.hibernate:com.springsource.org.hibernate:4.1.0.Final”
compile “org.hibernate.common:hibernate-commons-annotations:4.0.5.Final”
compile “org.hibernate:hibernate-core:4.3.11.Final”
compile “org.hibernate:hibernate-ehcache:4.3.11.Final”
compile “org.hibernate:hibernate-tools:4.3.5.Final”
compile “org.hibernate:hibernate-validator:4.3.2.Final”

In case I am trying to update the hibernate jars to 5.0.0.7 then after the deployment I am seeing 404 error.