sharad-garg
sharad-garg

Reputation: 469

Getting error NoClassDefFoundError after upgradting to Spring 3.2.4

I was on Spring 2.5 and was using Hibernate3.jar now I have upgraded to Spring 3.2.4 and still using Hibernate3.jar But on application load I am getting below error, Please help me if I am missing anything.

2013-10-25 23:20:19,513 ERROR [org.springframework.web.servlet.DispatcherServlet] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/eam/deploy/tfcc-admin.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

I have added following jar files in lib folder,

spring-aop-3.2.4.RELEASE.jar
spring-aspects-3.2.4.RELEASE.jar
spring-beans-3.2.4.RELEASE.jar
spring-context-3.2.4.RELEASE.jar
spring-context-support-3.2.4.RELEASE.jar
spring-core-3.2.4.RELEASE.jar
spring-expression-3.2.4.RELEASE.jar
spring-jdbc-3.2.4.RELEASE.jar
spring-orm-3.2.4.RELEASE.jar
spring-tx-3.2.4.RELEASE.jar
spring-web-3.2.4.RELEASE.jar
spring-webmvc-3.2.4.RELEASE.jar

SessionFactoryBean configuration:

<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="mappingResources">
            <list>
                <value>com/eam/hibernate/User.hbm.xml</value>
                <value>com/eam/hibernate/Branch.hbm.xml</value>
                <value>com/eam/hibernate/Address.hbm.xml</value>
            </list>
        </property>
    </bean>

Thanks.

Upvotes: 1

Views: 2175

Answers (3)

sharad-garg
sharad-garg

Reputation: 469

I resolved this issue my self by doing following things, 1. removed old hibernate3.jar and hibernate-annotation.jar and added two new jars

hibernate-commons-annotations-3.2.0.Final.jar
hibernate-core-3.6.10.Final.jar
persistence-api-1.0.jar

and Now i have following spring related jars in my classpath.

spring-aop-3.2.4.RELEASE.jar
spring-aspects-3.2.4.RELEASE.jar
spring-beans-3.2.4.RELEASE.jar
spring-context-3.2.4.RELEASE.jar
spring-context-support-3.2.4.RELEASE.jar
spring-core-3.2.4.RELEASE.jar
spring-expression-3.2.4.RELEASE.jar
spring-jdbc-3.2.4.RELEASE.jar
spring-orm-3.2.4.RELEASE.jar
spring-tx-3.2.4.RELEASE.jar
spring-web-3.2.4.RELEASE.jar
spring-webmvc-3.2.4.RELEASE.jar

Thanks,

Upvotes: 1

Crickcoder
Crickcoder

Reputation: 2155

  • Verify if you have still have hibernate3.jar in your classpath
  • Make sure you have remove the dependencies of old spring 2.5 jars. (But even if there is a clash it would have been NoClassDef with spring classes not hibernate
  • Check if you removed any jar on which hibernate3.jar was depending. This might not have allowed org/hibernate/context/CurrentSessionContext to initialize. (There could be an ExceptionInInitializerError in stacktrace)

I have listed down possible caused of NoClassDefFoundError here, may help you :

Debugging a NoClassDefFoundError

Upvotes: 0

baltov
baltov

Reputation: 194

Sorry, i can not find now info but i have memories about that. Try to replace it with:

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

Upvotes: 0

Related Questions