英文:
java.lang.NoClassDefFoundError: org/apache/naming/resources/FileDirContext
问题
当我将“.war”文件放入Apache Tomcat/8.5.39并尝试启动服务器时,出现以下错误:
java.lang.NoClassDefFoundError: org/apache/naming/resources/FileDirContext,但在之前的版本Tomcat 7.0.34中,它是正常工作的。
根本原因:
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)
我需要添加任何库或其他吗?
英文:
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 ?
答案1
得分: 1
org.apache.naming.resources
包在 Tomcat 8.0 中被移除,没有直接替代方案。在类路径中添加替代库也无法使其工作。
在发布说明和更改日志中均未提及该包的移除,因此我猜测 Tomcat 的作者将其视为内部功能。
您应该查看您的 StaticContentController
,了解为什么它依赖于 Tomcat 的 FileDirContext
,并用理想情况下不依赖于 Tomcat 内部功能的内容替代该依赖。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论