Eclipse 中的 Tomcat 7 启动错误 - 无法处理 JNDI URL
如果我在 Eclipse 中创建动态 Web 应用程序并且上下文根与 WAR 名称不匹配,则在启动关联的 Tomcat 7 服务器时会收到错误...
SEVERE: Unable to process JNDI URL [jndi:/localhost/tests/example1/WEB-INF/classes] for annotations
java.io.FileNotFoundException: jndi:/localhost/tests/example1/WEB-INF/classes
at org.apache.naming.resources.DirContextURLConnection.list(DirContextURLConnection.java:452)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1843)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1770)
等,
server.xml 的相关部分(我认为)文件是,
<Context docBase="MyExample" path="/tests/example1" reloadable="true" source="org.eclipse.jst.jee.server:MyExample"/>
正如我所期望的那样,可以通过 /tests/example1
访问应用程序,但是 servlet 注释不起作用,并且错误本身会导致服务器启动时间比应有的时间长。如果上下文根与 WAR 名称匹配,它就可以正常工作,但这对我来说将是一个问题。
我有什么想法可以解决这个问题吗?
更新:我发现只有修改后的上下文根包含 /
时才会发生这种情况。如果我将上下文根更改为“tests-example1”,它就可以工作。
If I create a dynamic web application in Eclipse and the context root doesn't match the WAR name, I get an error when starting up the associated Tomcat 7 server...
SEVERE: Unable to process JNDI URL [jndi:/localhost/tests/example1/WEB-INF/classes] for annotations
java.io.FileNotFoundException: jndi:/localhost/tests/example1/WEB-INF/classes
at org.apache.naming.resources.DirContextURLConnection.list(DirContextURLConnection.java:452)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1843)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1770)
etc,
The relevant part (I think) of the server.xml file is,
<Context docBase="MyExample" path="/tests/example1" reloadable="true" source="org.eclipse.jst.jee.server:MyExample"/>
The application is accessible via the /tests/example1
as I'd expect, but servlet annotations don't work and the error itself causes the server startup to take longer than it should. If the context root matches the WAR name, it works fine, but that will be a problem for me going forward.
Any ideas how I can work around this?
UPDATE: I've found this to only happen if the modified context root contains a /
. If I change the context root to "tests-example1" it works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 Tomcat 7.0.16 上遇到了同样的问题,但它适用于 Tomcat 7.0.22。
I had the same problem with Tomcat 7.0.16 but it works with Tomcat 7.0.22.
我们在使用 Tomcat 6.0.36 时遇到了这样的问题。我们在编辑 Spring 配置时找到了解决方案。我们在需要时更改
为
并将所有相对路径设置为固定路径。
也许,您的应用程序中的某些路径已更改,但您忘记更新应用程序配置。
所以,我认为,您应该首先检查您的应用程序配置。在 Spring 配置等中搜索“example1”。
We had such problem with Tomcat 6.0.36. We found the solution while editing the Spring configuration. We changed
to
and set all relative paths to fixed ones where needed.
Maybe, some paths were changed in your application, but you have forgot to update app configs.
So, I think, you should check your application configs first. Search for 'example1' in Spring configs, etc.