dos命令执行startup.bat启动tomcat,但是执行中途,窗口自动关闭,tomcat启动失败。查看cataline.log日志,发现提示如下
java.net.BindException: Cannot assign requested address: JVM_Bind at java.net.DualStackPlainSocketImpl.bind0(Native Method) at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190) at java.net.ServerSocket.bind(ServerSocket.java:375) at java.net.ServerSocket.<init>(ServerSocket.java:237) at org.apache.catalina.core.StandardServer.await(StandardServer.java:421) at org.apache.catalina.startup.Catalina.await(Catalina.java:776) at org.apache.catalina.startup.Catalina.start(Catalina.java:722) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
解决办法:
C:\Windows\System32\drivers\etc\hosts文件中的192.168.109.110 localhost 有关系注释或者删除掉之后再次启动tomcat成功启动了。
启动错误时C:\Windows\System32\drivers\etc\hosts文件内容
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
192.168.109.110 localhost
启动成功时C:\Windows\System32\drivers\etc\hosts文件内容
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
#192.168.109.110 localhost
192.168.109.110是一个不存在的本地IP地址,将hosts文件中的内容192.168.109.110 localhost去掉后,再次启动TOMCAT,发现运行正常!
在服务器领域,一台计算机配置多个IP地址是比较常见的。Tomcat在启动时,会根据配置去获取所有的IP地址,并且进行逐个绑定,当发现需要绑定的IP地址不存在时,将会触发上述异常,从而导致无法正常启动。
转载请注明:谷谷点程序 » tomcat启动窗口自动关闭java.net.BindException: Cannot assign requested address: JVM_Bind