Tomcat 未通过 Eclipse 启动(超时)

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

Tomcat Not Starting Through Eclipse (Timeout)

eclipsetomcat

提问by Orlan

I am trying to run Tomcat through Eclipse. This is something that I have done for the past several years. It was working yesterday and now it is not. The error I get is

我正在尝试通过 Eclipse 运行 Tomcat。这是我过去几年所做的事情。昨天还在用,现在不行了。我得到的错误是

Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

The Output is

输出是

Jul 06, 2012 8:32:26 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: D:\Program Files\Java\jdk1.7.0_05\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;D:\Launch;D:\Program Files\Java\jdk1.7.0_05\bin;%PROGRAMFILES%\Internet Explorer;C:\Program Files (x86)\SMLNJ\bin\;D:\Program Files\TortoiseSVN\bin;C:\ghc\ghc-6.6\bin;D:\Program Files\MySQL\MySQL Server 5.5\bin;%ANT_HOME%/bin;D:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\;D:\Program Files\Microsoft SQL Server0\Tools\Binn\;D:\Program Files\Microsoft SQL Server0\DTS\Binn\;D:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;D:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;D:\Program Files (86x)\;.
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 468 ms
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.28
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\docs
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\examples
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@5710ddf9')
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\host-manager
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\manager
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\ROOT
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 504 ms

I have looked around for a solution for several hours now. But I have not had any success and it likely is something simple. I have tried the following:

我已经环顾四周寻找解决方案几个小时了。但我没有取得任何成功,这可能很简单。我尝试了以下方法:

  1. Delete Serve and remake it in eclipse
  2. Restart computer, eclipse
  3. Reinstall eclipse, tomcat
  4. Start Eclipse with -clean
  5. Start server with no web app
  6. Increasing the timeout
  1. 删除Serve并在eclipse中重新制作
  2. 重启电脑,eclipse
  3. 重装eclipse、tomcat
  4. 使用 -clean 启动 Eclipse
  5. 在没有网络应用的情况下启动服务器
  6. 增加超时

I am able to start tomcat from command line just fine. However, I need to run it through eclipse to debug. I am aware ofthis SO postand have gone through it and many others to no avail.

我可以从命令行启动 tomcat 就好了。但是,我需要通过eclipse运行它来调试。我知道这个 SO post并且已经通过它和许多其他人无济于事。

Thoughts?

想法?

UPDATE: I just realized that the server does start up. However, one of the final functions that eclipse does, fails. How I observed this is by setting the timeout to 10 min. I was able to access the server during that time, however not the debug functionality of eclipse. So Eclipse starts it up, tries do something, that something never completes, Eclipse shuts down Tomcat after that timeout period.

更新:我刚刚意识到服务器确实启动了。但是,eclipse 执行的最终功能之一失败了。我是通过将超时设置为 10 分钟来观察这一点的。在那段时间我能够访问服务器,但不能访问 eclipse 的调试功能。所以 Eclipse 启动它,尝试做一些事情,有些事情永远不会完成,Eclipse 在超时时间后关闭 Tomcat。

UPDATE: Looking back at what happened around when this problem arose, the computer apparently installed a Java update.

更新:回顾出现此问题时发生的事情,计算机显然安装了 Java 更新。

回答by ekuusela

A Java update caused the same problem (among others) for me. The update caused Eclipse to use ipv6 when pinging Tomcat and for some reason that doesn't work with my setup.

Java 更新给我带来了同样的问题(以及其他问题)。该更新导致 Eclipse 在 ping Tomcat 时使用 ipv6,并且由于某些原因不适用于我的设置。

I fixed it by adding

我通过添加修复它

-Djava.net.preferIPv4Stack=true

To eclipse.ini.

eclipse.ini.

回答by David

I had a similar problem on my system (Windows 7 pro 64 bit), with Tomcat not starting from any Eclipse version. It turns out that by default Eclipse uses the system network configuration, and if you have configured a proxy that does not resolves localhost the Tomcat startup will hang in Eclipse!

我的系统(Windows 7 pro 64 位)也有类似的问题,Tomcat 没有从任何 Eclipse 版本开始。事实证明,默认情况下Eclipse 使用系统网络配置,如果您配置了一个不解析 localhost 的代理,Tomcat 启动将在 Eclipse 中挂起

To see if you have this problem go to Window -> Preferences -> General -> Network Connectionsand see if one of the boxes is checked. I was able to override my proxy configuration by setting Active Providerto Direct(it unchecks all boxes).

要查看您是否遇到此问题Window -> Preferences -> General -> Network Connections,请查看是否选中了其中一​​个框。我能够通过将Active Provider设置为Direct(它取消选中所有框)来覆盖我的代理配置。

回答by BigOnionTechnologies

I've found that this can happen due to invalid/corrupted/??? breakpoints in your code when you start in "Debug". It is often accompanied by slow start up times.

我发现这可能是由于无效/损坏/???在“调试”中开始时代码中的断点。它通常伴随着缓慢的启动时间。

"Remove All Breakpoints" cleared this up for me.

“删除所有断点”为我解决了这个问题。

回答by Mark

In my case, I had disabled the HTTP/1.1 Connector on port 8080 in favor of an SSLEnabled (https) HTTP/1.1 Connector on port 8443.

就我而言,我已禁用端口 8080 上的 HTTP/1.1 连接器,转而使用端口 8443 上的 SSLEnabled (https) HTTP/1.1 连接器。

I'm not sure if the Eclipse/Tomcat communication was failing because of the wrong port or the wrong protocol, but when I added the HTTP/1.1 Connector on port 8080 back into my server.xml (in addition to the secure connector on port 8443), Eclipse was able to correctly detect Tomcat's successful startup.

我不确定 Eclipse/Tomcat 通信是否因为错误的端口或错误的协议而失败,但是当我将端口 8080 上的 HTTP/1.1 连接器添加回我的 server.xml(除了端口上的安全连接器之外) 8443),Eclipse 能够正确检测到 Tomcat 的成功启动。

It appears that for Eclipse to recognize that Tomcat has successfully started, Tomcat must be configured to have a non-SSL Connector on port 8080.

看来,为了让 Eclipse 能够识别出 Tomcat 已成功启动,必须​​将 Tomcat 配置为在端口 8080 上具有非 SSL 连接器。

回答by idleworx

I was able to fix this issue by doing the following:

我能够通过执行以下操作来解决此问题:

  • Right-click on the Tomcat server (under the Eclipse Servers perspective)
  • Select Open - it should open up the xml editor
  • Look for the Timeouts section and increase the value to > 45s
  • 右键单击 Tomcat 服务器(在 Eclipse Servers 透视图下)
  • 选择打开 - 它应该打开 xml 编辑器
  • 查找 Timeouts 部分并将值增加到 > 45s

This works with Eclipse Helios / Tomcat 7

这适用于 Eclipse Helios / Tomcat 7

回答by Wayne Liu

Ran into same issue here. Tried out all these solutions the others proposed, none of it works for me.

在这里遇到同样的问题。尝试了其他人提出的所有这些解决方案,没有一个对我有用。

  1. change http 1.1 port to 8090.
  2. add -Djava.net.preferIPv4Stack=true to eclipse.ini (STS.ini in my case).
  3. in Window -> Preferences -> General -> Network Connections, set Active Provider to Direct or Manual.
  4. add 127.0.0.1 localhost to hosts localdns file (C:\Windows\System32\drivers\etc\hosts)
  1. 将 http 1.1 端口更改为 8090。
  2. 将 -Djava.net.preferIPv4Stack=true 添加到 eclipse.ini(在我的情况下为 STS.ini)。
  3. 在 Window -> Preferences -> General -> Network Connections 中,将 Active Provider 设置为 Direct 或 Manual。
  4. 将 127.0.0.1 localhost 添加到 hosts localdns 文件 (C:\Windows\System32\drivers\etc\hosts)

Finally I realized all this happens since I put the tomcat native library in. I removed it and reverted all the changes above, it works now. Anyway, thanks for all your helps which help me connect the issue with the native library.

最后我意识到这一切发生在我放入 tomcat 本地库之后。我删除了它并恢复了上面的所有更改,它现在可以工作了。无论如何,感谢您帮助我将问题与本机库联系起来的所有帮助。

回答by Nick

Well, I tried all these options, I could not get my recent version of STS (Spring Tool Suite 3.7.1.201510041213-RELEASE) to figure out that Tomcat had started.

好吧,我尝试了所有这些选项,但无法通过我最近版本的 STS(Spring Tool Suite 3.7.1.201510041213-RELEASE)来确定 Tomcat 已启动。

I tried Tomcat 7.0.64, 8.0.26, 8.0.28. All with the same results. I did get vanilla Tomcat installs to work, so I figured it must a problem with my server.xml (or other file).

我尝试了 Tomcat 7.0.64、8.0.26、8.0.28。所有的结果都是一样的。我确实让 vanilla Tomcat 安装工作,所以我认为它一定是我的 server.xml(或其他文件)有问题。

So I went through line by line until the server view would stop picking up the started status. Long story short, setting the secureattribute (to any value, like false) on a Connector causes STS to assume that it's another SSL handler.

所以我一行一行地浏览,直到服务器视图停止获取启动状态。长话短说,在连接器上设置secure属性(为任何值,例如false)会导致 STS 假定它是另一个 SSL 处理程序。

For example:

例如:

<Connector secure="false" executor="conPool" port="8080" redirectPort="8443" protocol="HTTP/1.1" />

Will cause STS to freak out, while:

会导致 STS 惊慌失措,同时:

<Connector executor="conPool" port="8080" redirectPort="8443" protocol="HTTP/1.1" />

Works as intended.

按预期工作。

It looks like STS assumes that by merely having the secure attribute, regardless of value, it's an SSL handler. Older versions of STS don't seem to have this problem though. Someone has already filed a very similar bug.

看起来 STS 假设仅具有安全属性,无论值如何,它都是 SSL 处理程序。不过,旧版本的 STS 似乎没有这个问题。有人已经提交了一个非常类似的错误

Also note that the server configuration pane shows:

另请注意,服务器配置窗格显示:

enter image description here

在此处输入图片说明

When the server.xml has the secureattribute on a non-SSL connector (and behavior is somewhat wonky), and:

当 server.xmlsecure在非 SSL 连接器上具有该属性时(并且行为有些不稳定),并且:

enter image description here

在此处输入图片说明

The normal ports listed when it is removed.

删除时列出的正常端口。

回答by jim.richards

I had messed around with my /etc/hosts file and removed the alias that I had set up in Eclipse. So

我弄乱了我的 /etc/hosts 文件并删除了我在 Eclipse 中设置的别名。所以

  1. Go to Window > Show View > Servers
  2. Double click on the Tomcat v7.0 (that's the version I've got)
  3. In the "Host name:" field check that you have a valid alias - if not sure, use localhost or check /etc/hosts or %systemroot%\system32\drivers\etc\hosts
  1. 转到窗口 > 显示视图 > 服务器
  2. 双击Tomcat v7.0(这是我得到的版本)
  3. 在“主机名:”字段中检查您是否有一个有效的别名 - 如果不确定,请使用 localhost 或检查 /etc/hosts 或 %systemroot%\system32\drivers\etc\hosts

Extending the timeout only delays the inevitable, it fixes the symptom not the cause.

延长超时只会延迟不可避免的事情,它可以解决症状而不是原因。

回答by jprusch

Make sure Tomcat is actually listening to 127.0.0.1 when host name is set to localhost.

当主机名设置为 localhost 时,确保 Tomcat 实际上正在侦听 127.0.0.1。

When starting the Tomcat server in Eclipse the log displays something like:

在 Eclipse 中启动 Tomcat 服务器时,日志显示如下:

10:07:23 INFO  main o.a.c.h.Http11NioProtocol Initializing ProtocolHandler ["http-nio-192.168.2.63-8080"]

Your Tomcat server configuration "Host name" and HTTP/1.1 Port MUST resolve to the displayed IP address & HTTP port (in the given example IP 192.168.2.63 Port 8080)

您的 Tomcat 服务器配置“主机名”和 HTTP/1.1 端口必须解析为显示的 IP 地址和 HTTP 端口(在给定的示例中 IP 192.168.2.63 端口 8080)

This fixed it with Eclipse 4.5 (Mars) & Tomcat 8

这用 Eclipse 4.5 (Mars) 和 Tomcat 8 修复了它

回答by Mohamed Challouf

Still facing the same issue after trying all the above solutions. i solved the problem by adding http connector to server.xml. In fact, before fixing the issue, i have only https connector. it seems that eclipse look for tomcat startup by requesting the http url, once removed eclipse can't determine if tomcat is successfully started.

在尝试了上述所有解决方案后,仍然面临同样的问题。我通过向 server.xml 添加 http 连接器解决了这个问题。事实上,在解决问题之前,我只有 https 连接器。似乎eclipse通过请求http url来寻找tomcat启动,一旦删除eclipse无法确定tomcat是否成功启动。