Announcement Announcement Module
Collapse
No announcement yet.
Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError

    I am trying to get Hibernate 3 working from Spring, I currently get this exception under Tomcat 5.5:

    Code:
    root cause 
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:403)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:306)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:251)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:220)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
    	javax.servlet.GenericServlet.init(GenericServlet.java:211)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
    	org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
    	org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
    	org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
    	org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	java.lang.Thread.run(Unknown Source)
    This is particularly useless as is does not give me the missing class name. Any ideas what it could be/why it does not give me a class name? Should I be supplying a class name somewhere but I am not?

    HTML Code:
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    		<property name="mappingLocations">
    			<value>/WEB-INF/test.hbm.xml</value>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">
    					org.hibernate.dialect.MySQLDialect
    				</prop>
    			</props>
    		</property>
    	</bean>

  • #2
    Do you have spring.jar and hibernate.jar in your classpath?

    Comment


    • #3
      I have hibernate3.jar and spring.jar, plus spring-hibernate.jar on my class path. As I was setting up this I have had other NoClassDefFoundError exceptions, but they have always given me the class names, e.g. for dom4j. Which enables me to add the jar, but now I do not have the name of the missing class.

      Comment


      • #4
        I imagine this error would be an error in the class loader, not supplying the classname in the exception.

        The jars are in tomcat/common/lib/

        Comment


        • #5
          Found a way past his, I moved all of the other jars from the application lib directory to common/lib, not sure which one it was though.

          Comment

          Working...
          X