java 一些 Tomcat webapps 打不开

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 10:51:34  来源:igfitidea点击:

Some Tomcat webapps not opening

javaspringtomcatweb-applications

提问by John Meagher

I downloaded a couple of webapps and placed them in my /webapps folder. Some of them I could open by going to http://localhost:8080/app1and it would open. However, some others I would do the exact same thing and go to http://localhost:8080/app2and it will display "HTTP Status 404 - /app2/", even though I am sure it is there. I've checked that it contains a WEB-INF folder just like app1, and I've even restarted Tomcat to be sure.

我下载了几个 webapps 并将它们放在我的 /webapps 文件夹中。其中一些我可以通过去http://localhost:8080/app1打开它会打开。但是,其他一些我会做完全相同的事情并转到http://localhost:8080/app2它会显示“HTTP 状态 404 - /app2/”,即使我确定它在那里。我已经检查过它是否包含一个 WEB-INF 文件夹,就像 app1 一样,我什至重新启动了 Tomcat 以确保。

My question is: is there anything (perhaps in the web.xml file) that specifies what the URL has to be to start the webapp? Or is it simply just http://localhost:8080/<folder name>?

我的问题是:是否有任何内容(可能在 web.xml 文件中)指定启动 web 应用程序的 URL 必须是什么?或者只是简单的http://localhost:8080/<folder name>

P.S. If you want to know exactly what app1 and app2 I am refering to: app1 (works) = http://assets.devx.com/sourcecode/11237.zipapp2 (doesn't work) = http://www.laliluna.de/download/eclipse-spring-jdbc-tutorial.zip

PS 如果您想确切地知道我指的是什么 app1 和 app2:app1(有效)= http://assets.devx.com/sourcecode/11237.zipapp2(无效)= http://www。 laliluna.de/download/eclipse-spring-jdbc-tutorial.zip

I've tried a few others as well, some work, some don't. I'm just wondering if I'm missing something.

我也试过其他一些,有些工作,有些没有。我只是想知道我是否遗漏了什么。

回答by Casey Watson

I usually debug this by going the the manager page and making sure that all of the contexts are deployed (http://localhost:8080/manager/html).

我通常通过进入管理器页面并确保所有上下文都已部署(http://localhost:8080/manager/html)来调试它。

It sounds like app2 has not been deployed properly or is not starting up because of some other error.

听起来 app2 未正确部署或由于其他错误而未启动。

I would look at the logs. There may be a bunch of information in there but usually it explains what is broken.

我会看日志。那里可能有一堆信息,但通常它会解释什么被破坏了。

回答by John Meagher

The first zip file you mention has a .warfile as part of the zip. The second one is just the source code and it needs to be built into a .warfile.

您提到的第一个 zip 文件有一个.war文件作为 zip 的一部分。第二个只是源代码,它需要构建到一个.war文件中。

It looks like it is setup to have that done in Eclipse. Try the File>>Exportoption and select War file as the export type.

看起来它已设置为在 Eclipse 中完成。尝试该File>>Export选项并选择 War 文件作为导出类型。

回答by Tom De Leu

The second app (the directory named WebRoot) can also be deployed correctly but you get a 404 by going to it because there is not an "index.jsp" or "index.html" file in the root directory.

第二个应用程序(名为 WebRoot 的目录)也可以正确部署,但转到它会得到 404,因为根目录中没有“index.jsp”或“index.html”文件。

Try putting a file there with any of those names, and the 404 is gone.

尝试使用这些名称中的任何一个放置一个文件,然后 404 就消失了。

A servlet mapping in the web.xml is not strictly necessary for this to work.

web.xml 中的 servlet 映射对于此工作并不是绝对必要的。

回答by Tony BenBrahim

The second requires the spring framework. The only runnable things I could find were a client in eclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\test\de\laliluna\library\TestClient.javaand one in eclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\de\laliluna\library\sample\MyApplication.java. If you open it in eclipse (it is an eclipse project), and compile, provided the Spring framework is installed, you should be able to run both.

第二个需要spring框架。我能找到的唯一可运行的东西是一个客户端 ineclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\test\de\laliluna\library\TestClient.javaeclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\de\laliluna\library\sample\MyApplication.java. 如果你在 eclipse 中打开它(它是一个 eclipse 项目),并编译,如果安装了 Spring 框架,你应该能够运行两者。

回答by enricopulatzo

Are you familiar with log4j? Spring puts a lot of often-useful information into the logs created via log4j. When I have a SpringMVC application that won't startup correctly or otherwise isn't running I check my log4j and potentially turn up the Spring log level to INFO or even DEBUG.

你熟悉 log4j 吗?Spring 将许多常用信息放入通过 log4j 创建的日志中。当我有一个无法正确启动或未运行的 SpringMVC 应用程序时,我会检查我的 log4j 并可能将 Spring 日志级别调至 INFO 甚至 DEBUG。

回答by Philip Helger

If "/" is not accessible it means that there is no "index.html", "index.jsp" or whatever is defined in the welcome-files list of the web.xml Also no Servlet-Mapping for the context ROOT directory is present. Check the web.xml for Servlet-Mappings or try to figure out the name of the jsp/html /... file being in the context root

如果“/”不可访问,则意味着没有“index.html”、“index.jsp”或 web.xml 的欢迎文件列表中定义的任何内容,也没有上下文 ROOT 目录的 Servlet-Mapping展示。检查 Servlet-Mappings 的 web.xml 或尝试找出上下文根中的 jsp/html /... 文件的名称