Recently I was working on an application and we were using tomcat 6 as the web container. We were changing from tomcat 6 to tomcat 7.
I wanted to do it very easy, so just copied the server.xml from tomcat 6 and pasted it into the tomcat 7 config folder. I did so that I don’t need to change the ports in the server.xml.
But as soon as I tried to start the tomcat 7 after these changes I started to get the below error:
Catalina.start: java.lang.ClassNotFoundException: org.apache.catalina.mbeans.ServerLifecycleListener java.lang.ClassNotFoundException: org.apache.catalina.mbeans.ServerLifecycleListener at java.net.URLClassLoader$1.run(URLClassLoader.java:198) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186 at java.lang.ClassLoader.loadClass(ClassLoader.java:299) at java.lang.ClassLoader.loadClass(ClassLoader.java:255) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:140) at org.apache.catalina.util.xml.ObjectCreate.start(XmlMapper.java:616) at org.apache.catalina.util.xml.XmlMapper.matchStart(XmlMapper.java:412) at org.apache.catalina.util.xml.XmlMapper.startElement(XmlMapper.java:91)
And after a bit of research I found out that simply copying the tomcat 6 server.xml is not the right thing to do. But what is recommended is to use the default tomcat7 and build on top of that.
As I went through the tomcat migration guide, I came to know that ServerLifecycleListener was no longer needed. So the above error was fixed by removing listener:
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
And i also added the following listeners:
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <Listener className="org.apache.catalina.security.SecurityListener" />
All the other configuration was same as the tomcat6.