0

I am trying to upgrade to Hibernate 4.3.8 and Spring 4.1.6 version. When I am trying to initialize the context getting the exception as below.

Caused by: java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.7.0_80]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2625) ~[na:1.7.0_80]
    at java.lang.Class.getDeclaredMethods(Class.java:1868) ~[na:1.7.0_80]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:571) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:488) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:501) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:474) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1065) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1038) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:860) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:790) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:542) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:436) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:412) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:186) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1105) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    ... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) ~[catalina.jar:7.0.59]
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) ~[catalina.jar:7.0.59]
    ... 49 common frames omitted

List of jars

spring-aop-4.1.6.RELEASE.jar spring-data-jpa-1.2.0.RELEASE.jar, spring-security-web-4.0.1.RELEASE.jar, spring-aspects-4.1.6.RELEASE.jar,spring-expression-4.1.6.RELEASE.jar,spring-test-4.1.6.RELEASE.jar,spring-batch-core-2.1.7.RELEASE.jar,spring-jdbc-4.1.6.RELEASE.jar,spring-tx-4.1.6.RELEASE.jar,spring-batch-infrastructure-2.1.7.RELEASE.jar,spring-orm-4.1.6.RELEASE.jar,spring-web-4.1.6.RELEASE.jar,spring-beans-4.1.6.RELEASE.jar,spring-oxm-4.1.6.RELEASE.jar,spring-webmvc-4.1.6.RELEASE.jar,spring-context-4.1.6.RELEASE.jar,spring-security-acl-4.0.1.RELEASE.jar,spring-webmvc-portlet-4.1.6.RELEASE.jar,spring-context-support-4.1.6.RELEASE.jar,spring-security-config-4.0.1.RELEASE.jar,spring-ws-core-2.1.3.RELEASE.jar,spring-core-4.1.6.RELEASE.jar,spring-security-core-4.0.1.RELEASE.jar,spring-xml-2.1.3.RELEASE.jar,spring-data-commons-core-1.4.0.RELEASE.jar,spring-security-taglibs-4.0.1.RELEASE.jar hibernate-c3p0-4.3.8.Final.jar hibernate-envers-4.3.8.Final.jar hibernate-search-engine-4.5.3.Final.jar hibernate-commons-annotations-4.0.5.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
hibernate-search-orm-4.5.3.Final.jar hibernate-core-4.3.8.Final.jar hibernate-jpamodelgen-4.3.8.Final.jar
hibernate-validator-5.1.3.Final.jar hibernate-ehcache-4.3.8.Final.jar hibernate-search-4.5.3.Final.jar hibernate-entitymanager-4.3.8.Final.jar
hibernate-search-analyzers-4.5.3.Final.jar

Ahsan 02
  • 61
  • 2
  • 15
  • 1
    Possible duplicate of [compatability of spring 4.0.0 with hibernate 4.30](http://stackoverflow.com/questions/21241210/compatability-of-spring-4-0-0-with-hibernate-4-30) – MWiesner Feb 12 '16 at 10:39

1 Answers1

0

Solution to your question

  1. You might be missing hibernate-core-4.3.8.Final.jar in your classpath. It has FilterDefinition class.
  2. Please add this dependency in your POM.xml file if you use Maven.

    <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-core</artifactId>
     <version>4.3.8.Final</version>
    </dependency>
    
Praveen Kumar K S
  • 3,024
  • 1
  • 24
  • 31
  • @ Gowtham, Please check if this exception still persists. – Praveen Kumar K S Feb 12 '16 at 11:12
  • Still issue persists. I have added hibernate-core-4.3.8.Final.jar and spring-orm-4.1.6.RELEASE.jar and in my property file org.springframework.orm.hibernate4.LocalSessionFactoryBean for sessionFactory and org.springframework.orm.hibernate4.HibernateTransactionManager for transaction manager. – Gowtham Thurangi Feb 12 '16 at 11:22
  • @Gowtham, Please ensure you have **only** added the **SpringFramework 4.1.6 Bill of Materials (https://repo1.maven.org/maven2/org/springframework/spring-framework-bom/4.1.6.RELEASE/spring-framework-bom-4.1.6.RELEASE.pom)** jar files in your classpath. – Praveen Kumar K S Feb 12 '16 at 11:35
  • Yes I have added all the dependencies in my classpath. – Gowtham Thurangi Feb 12 '16 at 12:05
  • @GowthamThurangi, Please add your configuration files in your question for better clarity. Also add your POM.xml (if you use) and list of dependent Jar files used in application. – Praveen Kumar K S Feb 12 '16 at 12:30
  • . I was not able to upload my configuration file. – Gowtham Thurangi Feb 12 '16 at 13:08
  • 1
    You have to use LocalSessionFactoryBean to integrate with Hibernate and for transactions you to have use HibernateTransactionManager. This following link (http://www.baeldung.com/hibernate-4-spring) will serve a good example – Praveen Kumar K S Feb 12 '16 at 13:19