NoClassDefFoundError in spring


I wrote a Spring application which runs on Weblogic 10.3. In this application I have some JMS Queue consumers.

Sometimes I got an error when the application is closing or opening (I saw this error in both situation) saying:

    java.lang.NoClassDefFoundError: org/springframework/jms/connection/SmartConnectionFactory
        at org.springframework.jms.connection.ConnectionFactoryUtils.releaseConnection(
        at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection( org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(
        at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(
        at org.springframework.jms.listener.DefaultMessageListenerContainer$
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.connection.SmartConnectionFactory
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(
        at weblogic.utils.classloaders.GenericClassLoader.findClass(
        at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at weblogic.utils.classloaders.GenericClassLoader.loadClass(
        at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(
        ... 6 more

Why do I get this error and what should I do to solve it? The version of the spring.jar is 2.5.5


It's all very well that you have this class in your war, but in Weblogic, the war has its own classloader. Since your stack trace shows a JMS listener, I'd ask: where is the listener? If it's in the war, then you have a mystery. But it sure looks as though it's somewhere else, and it's that somewhere else that would be missing this Spring class.

That Exception means that the class is not getting loaded into the JVM. Make sure that the spring.jar is in the Weblogic server's classpath or library folder.

This video can help you solving your question :)
By: admin