简体   繁体   English

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

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

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\10.2.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Common Files\Teleca Shared;C:\Program Files\Microsoft SQL Server\90\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:8085 in webbrowser, it is giving me the following error:但是当我尝试在 webbrowser 中打开http://localhost:8085时,它给了我以下错误:

HTTP Status 404 - / HTTP 状态 404 - /

type Status report类型状态报告

message /留言/

description The requested resource (/) is not available.描述请求的资源 (/) 不可用。

Apache Tomcat/6.0.24 Apache Tomcat/6.0.24

When I start Tomcat outside the Eclipse, then I can just open http://localhost:8085 in webbrowser.当我在 Eclipse 之外启动 Tomcat 时,我可以在 webbrowser 中打开http://localhost:8085

What could be the reason for this?这可能是什么原因? How do I solve this problem?我该如何解决这个问题?

What are you expecting?你在期待什么? The default Tomcat homepage?默认的Tomcat主页? If so, you'll need to configure Eclipse to take control over from Tomcat.如果是这样,您需要配置 Eclipse 以从 Tomcat 接管控制。

Doubleclick the Tomcat server entry in the Servers tab, you'll get the server configuration.双击Servers选项卡中的 Tomcat 服务器条目,您将获得服务器配置。 At the left column, under Server Locations , select Use Tomcat installation .在左列的Server Locations 下,选择Use Tomcat installation 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.这样 Eclipse 将完全控制 Tomcat,这样您还可以在从 Eclipse 内部运行时使用 Tomcat 管理器访问默认的 Tomcat 主页。 I only don't see how that's useful while developing using Eclipse.我只是不明白这在使用 Eclipse 进行开发时有什么用处。

在此处输入图片说明

Note, when it is grayed out, read the section leading text!请注意,当它变灰时,请阅读部分前导文本! It literally says "Server must be published with no modules present to make changes" .它的字面意思是“必须在不存在模块的情况下发布服务器才能进行更改” In other words, make sure that you've removed all modules via rightclick server and Add and remove... option, and then performed rightclick server and Publish .换句话说,请确保您已通过右键单击服务器和添加和删​​除...选项删除所有模块,然后执行右键单击服务器和发布

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 未启动和运行时,该页面不可能提供服务。

Eclipse hooks Dynamic Web projects into tomcat and maintains it's own configuration but does not deploy the standard tomcat ROOT.war. Eclipse 将动态 Web 项目挂接到 tomcat 并维护它自己的配置,但不部署标准的 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.由于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/yourprojectname working 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.希望有帮助。

Right-click on your project's name in Eclipse's Project Explorer, then click Run As followed by Run on Server.在 Eclipse 的 Project Explorer 中右键单击您的项目名称,然后单击 Run As,然后单击 Run on Server。 Click the Next button.单击下一步按钮。 Make sure your project's name is listed in the Configured: column on the right.确保您的项目名称列在右侧的 Configured: 列中。 If it is, then you should be able to access it with this URL:如果是,那么您应该可以使用以下 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.此外,无论何时向项目添加新内容(例如新的 JSP、图形或其他资源),请务必通过单击其名称然后按 F5 来刷新项目。 Otherwise Eclipse does not know that those new resources are available and will not make them available to Tomcat to serve.否则 Eclipse 不知道这些新资源可用,并且不会将它们提供给 Tomcat 来提供服务。

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/Applicationname it will give output and also check http://localhost:8080/Applicationname/index.jsp使用http://localhost:8080/Applicationname运行应用http://localhost:8080/Applicationname ,它将提供输出并检查http://localhost:8080/Applicationname/index.jsp

You need to start the Apache Tomcat services.您需要启动Apache Tomcat服务。

Win+R --> sevices.msc Win+R --> 服务.msc

Then, search for Apache Tomcat and right click on it and click on Start.然后,搜索 Apache Tomcat 并右键单击它并单击开始。 This will start the service and then you'll be able to see Apache Tomcat homepage on the localhost .这将启动服务,然后您将能够在localhost上看到 Apache Tomcat 主页。

I may be out fishing here, but doesn't Tomcat by default open to port 8080?我可能会在这里钓鱼,但是默认情况下 Tomcat 不是打开端口 8080 的吗? Try http://localhost:8080 instead.改为尝试http://localhost:8080

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM