我无法使用 Eclipse 启动 Tomcat 服务器

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

I can't start Tomcat Server using Eclipse

eclipsejakarta-eetomcat

提问by Koray Tugay

I simply defined a new Server using Eclipse Juno. I picked a folder and downloaded and installed Tomcat Server.

我只是使用 Eclipse Juno 定义了一个新服务器。我选择了一个文件夹并下载并安装了 Tomcat 服务器。

This is the log when I start the server: ( No deployment or anything, just server starting. )

这是我启动服务器时的日志:(没有部署或任何东西,只是服务器启动。)

Mar 10, 2013 8:38:13 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\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x64;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\PHP;C:\PHP\PEAR;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\;C:\Program Files (x86)\Git\cmd;C:\Program Files\Java\jdk1.6.0_37\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\apache-maven-2.2.1\bin;.
Mar 10, 2013 8:38:14 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Mar 10, 2013 8:38:14 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Mar 10, 2013 8:38:14 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 480 ms
Mar 10, 2013 8:38:14 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 10, 2013 8:38:14 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Mar 10, 2013 8:38:14 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 10, 2013 8:38:14 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 10, 2013 8:38:14 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 167 ms

But when I navigate to localhost:8080 all I see is:

但是当我导航到 localhost:8080 时,我看到的是:

HTTP Status 404 - /

type Status report

message /

description The requested resource (/) is not available.

Apache Tomcat/7.0.12

I am sure that port number of the server is 8080.

我确定服务器的端口号是 8080。

Edit 1:

编辑1:

This is the web.xml file from the Tomcat Folder that is downloaded:

这是下载的 Tomcat 文件夹中的 web.xml 文件:

<servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>0</param-value>
    </init-param>
    <init-param>
        <param-name>listings</param-name>
        <param-value>false</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup> </servlet>


<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern> </servlet-mapping>

Edit 2:

编辑2:

I solved my problem: I changed the Server Location in Eclipse from Use workspace metadata to Use Tomcat installation. Now it works..

我解决了我的问题:我将 Eclipse 中的服务器位置从使用工作区元数据更改为使用 Tomcat 安装。现在它起作用了..

Thanks everyone!

谢谢大家!

回答by Art Licis

Don't get confused by the error code: HTTP 404 means that client (browser) was able to connect to server, but it didn't find the required resource -- in your case it's root "/".

不要被错误代码弄糊涂了:HTTP 404 意味着客户端(浏览器)能够连接到服务器,但它没有找到所需的资源——在你的情况下它是根“/”。

Since you are starting Tomcat from the Eclipse environment, it doesn't publish anything but what you have defined in your "Servers"/Tomcat configuration. This behavior is well described in this FAQ: WTP Tomcat FAQ. In your case you didn't do any configuration, so there's no deployed content.

由于您是从 Eclipse 环境启动 Tomcat,因此除了您在“服务器”/Tomcat 配置中定义的内容之外,它不会发布任何内容。此常见问题解答中详细描述了此行为:WTP Tomcat 常见问题解答。在您的情况下,您没有进行任何配置,因此没有部署的内容。

As soon as you start developing your web project, you'll be able to access any published resources.

一旦开始开发 Web 项目,您就可以访问任何已发布的资源。

回答by hd1

Eclipse starts Tomcatwith your app as the only webapp.

Eclipse以您的应用程序作为唯一的 Web 应用程序启动Tomcat

回答by Hemanth

You now need to create a 'servlet' and a 'servlet-mapping' entry in your web.xml.

您现在需要在 web.xml 中创建一个“servlet”和一个“servlet-mapping”条目。

Once you do, you can get rid of the "servlet/" part of your url.

完成后,您可以删除 url 的“servlet/”部分。

Check out the following URL for more information regarding the invoker servlet: http://faq.javaranch.com/view?InvokerServlet

有关调用程序 servlet 的更多信息,请查看以下 URL:http: //faq.javaranch.com/view?InvokerServlet

Source: www.coderanch.com

资料来源:www.coderanch.com

回答by Doug

If you don't have a ROOT web application, navigating to / and getting a 404 might be the expected behavior.

如果您没有 ROOT Web 应用程序,导航到 / 并获得 404 可能是预期的行为。

Can you navigate to the context of one of your deployed web applications after running the web application?

运行 Web 应用程序后,您能否导航到您部署的 Web 应用程序之一的上下文?

If not, can we see the errors in the logs when you attempt this? What you're showing looks like a good Tomcat log. It doesn't really indicate any issues.

如果没有,我们可以在您尝试此操作时看到日志中的错误吗?您显示的内容看起来像是一个不错的 Tomcat 日志。它并没有真正表明任何问题。