I’m recently working on a large online website and using Tomcat in development phase, I broke the tomcat so that I got the NoClassDefFoundError exception. Here is the stack trace of NoClassDefFoundError.

ClassNotFoundException: com.sap.mw.jco.rfc.MiddlewareRFC
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at SecurePaymentAjaxData.doPost(SecurePaymentAjaxData.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)


When ClassNotFoundException is occurring, this is to say that the class loader is not able to find the class binary file in webapp classpath (the jars in mywebapp/WEB-INF/lib). Same situation also happens to NoClassDefFoundError. If you have same issue it is strongly recommended you follow the below:

  1. Check whether or not the required Jar is listed in WEB-INF/lib folder of your WAR? If not add it.
  2. If the Jar has included in classpath, check whether the class exists in this Jar package.
  3. Try to restart tomcat.