Tomcat 在 Eclipse 中启动但无法连接到 http://localhost:8085/

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2280064/
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-09-10 19:12:22  来源:igfitidea点击:

Tomcat started in Eclipse but unable to connect to http://localhost:8085/

eclipsetomcathttp-status-code-404

提问by komal

I configured Tomcat 6.0.24 in Eclipse on port 8085 and started successfully with log as below:

我在 Eclipse 中的 8085 端口上配置了 Tomcat 6.0.24 并成功启动,日志如下:

Feb 17, 2010 4:24:31 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;E:\oracle\product.2.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\Microsoft SQL Server\Tools\BINN;C:\Program Files\Common Files\Teleca Shared;C:\Program Files\Microsoft SQL Server\Tools\binn\;E:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files\MySQL\MySQL Server 5.0\bin;E:\komal-gohil\tools\Subversion\bin;C:\Sun\SDK\bin;e:\instantrails\ruby\bin;c:\program files\java\jdk1.6.0_11\bin;E:\komal-gohil\tools\apache-maven-2.2.1\bin;C:\program files\java\jdk1.6.0_11\bin;E:\komal-gohil\tools\Ant\bin;E:\komal-gohil\tools\apache-tomcat-5.5.17\bin;C:\Sun\SDK\lib\j2ee.jar;E:\komal-gohil\tools\android-sdk-windows-1.6_r1\tools;E:\komal-gohil\tools\Scala\bin;E:\komal-gohil\tools\pax-construct-1.4\bin
Feb 17, 2010 4:24:31 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8085
Feb 17, 2010 4:24:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 705 ms
Feb 17, 2010 4:24:32 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 17, 2010 4:24:32 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Feb 17, 2010 4:24:32 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8085
Feb 17, 2010 4:24:32 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8010
Feb 17, 2010 4:24:32 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31  config=null
Feb 17, 2010 4:24:32 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 421 ms

But when I am trying to open http://localhost:8085in webbrowser, it is giving me the following error:

但是当我尝试http://localhost:8085在 webbrowser 中打开时,它给了我以下错误:

HTTP Status 404 - /

typeStatus report

message/

descriptionThe requested resource (/) is not available.

Apache Tomcat/6.0.24

HTTP 状态 404 - /

类型状态报告

留言/

描述请求的资源 (/) 不可用。

Apache Tomcat/6.0.24

When I start Tomcat outside the Eclipse, then I can just open http://localhost:8085in webbrowser.

当我在 Eclipse 之外启动 Tomcat 时,我可以http://localhost:8085在 webbrowser 中打开。

What could be the reason for this? How do I solve this problem?

这可能是什么原因?我该如何解决这个问题?

回答by BalusC

What are you expecting? The default Tomcat homepage? If so, you'll need to configure Eclipse to take control over from Tomcat.

你在期待什么?默认的Tomcat主页?如果是这样,您需要配置 Eclipse 以从 Tomcat 接管控制。

Doubleclick the Tomcat server entry in the Serverstab, you'll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation(note, when it is grayed out, readthe section leading text! ;) ). This way Eclipse will take full control over Tomcat, this way you'll also be able to access the default Tomcat homepage with the Tomcat Manager when running from inside Eclipse. I only don't see how that's useful while developing using Eclipse.

双击Servers选项卡中的 Tomcat 服务器条目,您将获得服务器配置。在左列的Server Locations 下,选择Use Tomcat installation(注意,当它变灰时,请阅读前导文本部分!;))。这样 Eclipse 将完全控制 Tomcat,这样您还可以在从 Eclipse 内部运行时使用 Tomcat 管理器访问默认的 Tomcat 主页。我只是不明白这在使用 Eclipse 进行开发时有什么用处。

enter image description here

在此处输入图片说明

The port number is not the problem. You would otherwise have gotten an exception in Tomcat's startup log, and the browser would show a browser-specific "Connection timed out" error page and thus not a Tomcat-specific error page which could impossibly be served when Tomcat was not up and running.

端口号不是问题。否则,您会在 Tomcat 的启动日志中遇到异常,并且浏览器会显示特定于浏览器的“连接超时”错误页面,因此不会显示特定于 Tomcat 的错误页面,当 Tomcat 未启动和运行时,该页面不可能提供服务。

回答by beny23

Eclipse hooks Dynamic Web projects into tomcat and maintains it's own configuration but does not deploy the standard tomcat ROOT.war. As http://localhost:8085/link returns 404 does indeed show that tomcat is up and running, just can't find a web app deployed to root.

Eclipse 将动态 Web 项目挂接到 tomcat 并维护它自己的配置,但不部署标准的 tomcat ROOT.war。由于http://localhost:8085/链接返回 404 确实表明 tomcat 已启动并正在运行,只是找不到部署到 root 的 Web 应用程序。

By default, any deployed dynamic web projects use their project name as context root, so you should see http://localhost:8085/yourprojectnameworking properly, but check the Servers tab first to ensure that your web project has actually been deployed.

默认情况下,任何已部署的动态 Web 项目都使用其项目名称作为上下文根,因此您应该看到http://localhost:8085/yourprojectname正常工作,但首先检查 Servers 选项卡以确保您的 Web 项目已实际部署。

Hope that helps.

希望有帮助。

回答by Brian Showalter

Right-click on your project's name in Eclipse's Project Explorer, then click Run As followed by Run on Server. Click the Next button. Make sure your project's name is listed in the Configured: column on the right. If it is, then you should be able to access it with this URL:

在 Eclipse 的 Project Explorer 中右键单击您的项目名称,然后单击 Run As,然后单击 Run on Server。单击下一步按钮。确保您的项目名称列在右侧的 Configured: 列中。如果是,那么您应该可以使用以下 URL 访问它:

http://localhost:8085/projectname/

Additionally, whenever you make new additions (such as new JSPs, graphics or other resources) to your project, be sure to refresh the project by clicking on its name and then hitting F5. Otherwise Eclipse does not know that those new resources are available and will not make them available to Tomcat to serve.

此外,每当您向项目添加新内容(例如新的 JSP、图形或其他资源)时,请务必通过单击其名称然后按 F5 来刷新项目。否则 Eclipse 不知道这些新资源可用,并且不会将它们提供给 Tomcat 来提供服务。

回答by Karthik Reddy

You can change the port number:

您可以更改端口号:

Open the server tab in eclipse -> right click open click on open---->you can change the port number.

在eclipse中打开server选项卡->右键打开点击打开---->可以更改端口号。

Run the application with http://localhost:8080/Applicationnameit will give output and also check http://localhost:8080/Applicationname/index.jsp

http://localhost:8080/Applicationname它运行应用程序将提供输出并检查 http://localhost:8080/Applicationname/index.jsp

回答by Germa Vinsmoke

You need to start the Apache Tomcatservices.

您需要启动Apache Tomcat服务。

Win+R --> sevices.msc

Win+R --> 服务.msc

Then, search for Apache Tomcat and right click on it and click on Start. This will start the service and then you'll be able to see Apache Tomcat homepage on the localhost.

然后,搜索 Apache Tomcat 并右键单击它并单击开始。这将启动服务,然后您将能够在localhost.

回答by mikek

I may be out fishing here, but doesn't Tomcat by default open to port 8080? Try http://localhost:8080instead.

我可能会在这里钓鱼,但是默认情况下 Tomcat 不是打开端口 8080 的吗?改为尝试http://localhost:8080