tomcat7 中的 javax.naming.NameNotFoundException
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设 Web 应用程序的结构为
TestApp
->网页内容
-> WEB-INF
您可以如下所示设置 docBase。
当 docBase 仅设置为上下文名称时,会出现错误。
Assuming the structure of a web application as
TestApp
-> WebContent
-> WEB-INF
you may set docBase as shown below.
The error arises when docBase is set to the context name only.
这意味着您的 .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 directoryWEB-INF
which is meant to provide meta-data for the web-app such as e.g.web.xml
. Or theclasses
directory withinWEB-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)