java.lang.NoClassDefFoundError: org/apache/naming/resources/FileDirContext

huangapple go评论51阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月8日 19:39:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385258.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定