NoClassDefFoundError on org.springframework.jms.listener.DefaultMessageListenerContainer during Tomcat restart

1.6k views Asked by At

Our application has a listener that consumes messages from ActiveMQ broker. However, in the production environment, we have added script to restart the Tomcat server daily. Following is the script that restart the tomcat SERVICE in the production server;

date /t >> Restart_Production_Tomcats.log
time /t >> Restart_Production_Tomcats.log
echo "Restart Tomcat Production Server" >> Restart_Production_Tomcats.log
net stop "Application1" >> Restart_Production_Tomcats.log timeout /T 60 /NOBREAK
net start "Application1" >> Restart_Production_Tomcats.log
time /t >> Restart_Production_Tomcats.log
echo "Restart_Production_Tomcats completed" >> Restart_Production_Tomcats.log 
echo "" >> Restart_Production_Tomcats.log 

Normally, during the restart, log file get following exception one time at each restart;

Exception in thread "org.springframework.jms.listener.DefaultMessageListenerContainer#0-3834" java.lang.NoClassDefFoundError: org/springframework/jms/connection/SmartConnectionFactory 
at org.springframework.jms.connection.ConnectionFactoryUtils.releaseConnection(ConnectionFactoryUtils.java:71) 
at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:386) 
at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:869) 
at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:851) 
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:982) 
at java.lang.Thread.run(Thread.java:722)

However, one particular day I got more than 3000 such exceptions, on that days even Tomcat couldn't restart properly. For me, it seems like JVM classloader can not find org.springframework.jms.listener.DefaultMessageListenerContainer class during the restart.

Can someone please explain what is happening when restarting tomcat and why I got this exception? However, in our development environment I can not replicate this issue or even we can not see this issue in other production environment. Is it due to restart the Tomcat server while processing messages from the ActiveMQ by listener? or some issue with restart script?

I found similar question, NoClassDefFoundError in spring However, I couldn't find clear answer for my question with this question.

0

There are 0 answers