When i have placed ".war" file in Apache Tomcat/8.5.39 and tried to start server getting the below error java.lang.NoClassDefFoundError: org/apache/naming/resources/FileDirContext but in previous version tomcat 7.0.34 its working fine
Root Cause
java.lang.NoClassDefFoundError: org/apache/naming/resources/FileDirContext com.anz.fit.fitas.tomcat.share.StaticContentController.initResources(StaticContentController.java:127) com.anz.fit.fitas.tomcat.share.StaticContentController.doGet(StaticContentController.java:63) javax.servlet.http.HttpServlet.service(HttpServlet.java:635) org.apache.catalina.servlets.DefaultServlet.service(DefaultServlet.java:418) javax.servlet.http.HttpServlet.service(HttpServlet.java:742) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
Do i need to add any library or else ?
The org.apache.naming.resources
package got removed in Tomcat 8.0 with no direct replacement. There is no alternative library you could add to the classpath to make it work.
Neither the release notes nor the changelog mentions the removal of that package, so I guess the Tomcat authors regarded it as internal.
You should look at your StaticContentController
to understand why it has a dependency on on Tomcat's FileDirContext
, and replace that dependency with something ideally not dependent on Tomcat internals.