tomcat7 中的 javax.naming.NameNotFoundException

发布于 2025-01-01 22:14:33 字数 2408 浏览 1 评论 0原文

我在 tomcat7 错误中遇到以下错误

javax.naming.NameNotFoundException: Resource /WEB-INF/classes not found
        at org.apache.naming.resources.BaseDirContext.listBindings(BaseDirContext.java:733)
        at org.apache.naming.resources.ProxyDirContext.listBindings(ProxyDirContext.java:546)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1197)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:825)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:300)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

我通过以下 server.xml 文件中的条目访问内容(类和 jsp 文件)

<Host name="test" debug="0" appBase="path where classes and WEB-INF resides"
                unpackWARs="false" autoDeploy="false">

                <Logger className="org.apache.catalina.logger.FileLogger"
                    prefix="om_log." suffix=".log"
                    timestamp="true"/>

        <Context path="" docBase="path where classes and WEB-INF resides" debug="0"
               reloadable="false" crossContext="false" />
       </Host>

I am getting following error in tomcat7

error:

javax.naming.NameNotFoundException: Resource /WEB-INF/classes not found
        at org.apache.naming.resources.BaseDirContext.listBindings(BaseDirContext.java:733)
        at org.apache.naming.resources.ProxyDirContext.listBindings(ProxyDirContext.java:546)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1197)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:825)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:300)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

I am accessing content (classes and jsp file) by following entry inside server.xml file

<Host name="test" debug="0" appBase="path where classes and WEB-INF resides"
                unpackWARs="false" autoDeploy="false">

                <Logger className="org.apache.catalina.logger.FileLogger"
                    prefix="om_log." suffix=".log"
                    timestamp="true"/>

        <Context path="" docBase="path where classes and WEB-INF resides" debug="0"
               reloadable="false" crossContext="false" />
       </Host>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

又爬满兰若 2025-01-08 22:14:33

假设 Web 应用程序的结构为

TestApp
->网页内容
-> WEB-INF
您可以如下所示设置 docBase。

<Context path="/TestApp" docBase="C:/project/TestApp/webapp" debug="0"
           reloadable="false" crossContext="false" />

appBase="webapps"

当 docBase 仅设置为上下文名称时,会出现错误。

docBase="C:/project/TestApp"

Assuming the structure of a web application as

TestApp
-> WebContent
-> WEB-INF
you may set docBase as shown below.

<Context path="/TestApp" docBase="C:/project/TestApp/webapp" debug="0"
           reloadable="false" crossContext="false" />

appBase="webapps"

The error arises when docBase is set to the context name only.

docBase="C:/project/TestApp"
如何视而不见 2025-01-08 22:14:33

这意味着您的 .war 文件(压缩形式)不包含目录 WEB-INF ,该目录旨在为网络应用程序提供元数据,例如例如 web.xml 。或者 WEB-INF 中的 classes 目录,其中包含 Web 应用程序的可执行类(例如 servlet 代码)。

目录名称“WEB-INF”需要全部大写。如果您使用的是 Windows,则可能您输入的是小写字母,但 Windows zip 实用程序显示为大写字母)

That means that your .war file (in its zipped form) does not contain a directory WEB-INF which is meant to provide meta-data for the web-app such as e.g. web.xml . Or the classes directory within WEB-INF which holds the executable classes of your web-app (e.g. servlet code).

The directory name "WEB-INF" needs to be all uppercase. If you are on Windows, it may be that you have typed it in lower case, but windows zip utility shows it in upper case)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文