Tomcat无法启动:java.net.BindException:无法分配请求的地址

时间:2012-05-24 08:55:47

标签: tomcat

当我启动Tomcat的语言环境实例时,我收到以下错误:

    SEVERE: StandardServer.await: create[8005]: 
    java.net.BindException: Cannot assign requested address: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
    at java.net.ServerSocket.bind(ServerSocket.java:319)
    at java.net.ServerSocket.<init>(ServerSocket.java:185)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:373)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:662)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:614)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

我在论坛上看到过人们有同样的问题。 Netstat未显示正在使用的端口8080,8005或8009。我试图改变端口,但我得到了同样的错误。我还检查了hosts文件 Windows \ System32 \ drivers \ etc和行

127.0.0.1       localhost

未评论。我没有更改server.xml中的任何内容,因为昨天我无法让它工作。 有什么想法吗?

编辑:

<Server port="8005" shutdown="SHUTDOWN">

Connectors:
 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000" 
               redirectPort="8443" />

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

谢谢你的帮助

8 个答案:

答案 0 :(得分:10)

我通过指定

解决了这个问题

<Server address="0.0.0.0" port="8005" shutdown="SHUTDOWN">

在conf / server.xml。

答案 1 :(得分:6)

您的服务器的IP已更改(甚至是您不使用的其他网卡的IP),您必须进行编辑。

C:\Windows\System32\drivers\etc\hosts

答案 2 :(得分:3)

最可能的原因是:您的localhost的IP地址未在主机文件中正确配置。 验证主机文件: 运行:system32:drivers:etc:host 在记事本中打开此主机文件

将此localhost行保留为主机文件中的第1行。 关闭一切。 从Eclipse中删除服务器并重新配置它。 它应该有所帮助。

答案 3 :(得分:3)

在我的情况下,这是主机文件(Windows)的问题。 实际上我从一开始就有以下条目...     172.16.xxx.yyy localhost

大约两周前,我们公司进行了物理服务器和网络域拆分活动,这改变了所有机器的IP。 在这里,我的yyy被改变了。

当我编辑我的IP时,错误消失了。 谢谢Saurabh Chande。

答案 4 :(得分:2)

我设法解决了这个问题。

我在Eclipse中遇到了与本地tomcat相同的问题(它无法启动,因为它无法找到tomcat.bin)。 我右键单击Eclipse中Servers选项卡中的Tomcat服务器并单击属性。在常规属性中有一个“切换位置”按钮。它曾经指向Eclipse上的本地Tomcat,但是使用此按钮将其更改为C盘上实际安装Tomcat的文件夹。现在Tomcat正在Eclipse和localy中工作。

答案 5 :(得分:0)

如果未正确设置hosts文件的权限,我在服务器上遇到此问题

正在运行now = Math.abs(now - timeSinceYouCalculatingDiff); end = Math.abs(end - timeSinceYouCalculatingDiff); // Note timeSinceYouCalculatingDiff should be less than now and end dates 更正了问题。

答案 6 :(得分:0)

第1步: 转到C:\ Windows \ System32 \ drivers \ etc

第2步:

找到主机文件并使用带有管理员模式的记事本打开它

第3步:

用127.0.0.1替换本地主机IP

例如

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost
#   ::1             localhost

第4步:

保存该文件并运行服务器

答案 7 :(得分:0)

我知道在此线程中发布消息有点晚了,但是我想帮助那些正在寻找答案并且遇到类似于我的问题的人。而且我没有足够的代表,因此无法发表评论。

OP发布后,

  

我还检查了Windows \ System32 \ drivers \ etc和该行中的主机文件

     

127.0.0.1 localhost

     

未评论。我没有更改server.xml中的任何内容,并且从昨天开始我无法使其正常工作。有什么想法吗?

我想对此部分发表评论。对于我来说,下面的行也没有评论。

127.0.0.1 localhost

但是,还有另一行将“ localhost”绑定到旧的本地IP。

127.0.0.1 localhost 10.10.1.123 localhost

由于路由器的重新配置,最近更改的是我原来的本地IP,这是罪魁祸首。因此,评论重复的行解决了我的问题。

结论是,除了检查回送IP是否已注释之外,还要检查“ localhost”是否存在多个绑定。

相关问题