eclipse 无法启动 Tomcat 7 服务器 - java.net.BindException:地址已在使用中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14271828/
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
cannot start Tomcat 7 server - java.net.BindException: Address already in use
提问by user1844638
Hi i am not able to start tomcat 7 server from eclipse.
嗨,我无法从 Eclipse 启动 tomcat 7 服务器。
When i give start from eclipse i get the following error log.
当我从 Eclipse 开始时,我收到以下错误日志。
Jan 11, 2013 10:10:27 AM 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/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\Jayant\Desktop\data\adt-bundle-windows-x86\eclipse;;.
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:10:28 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1165 ms
Jan 11, 2013 10:10:28 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 11, 2013 10:10:28 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:10:28 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 507 ms
Jan 11, 2013 10:10:28 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:422)
at org.apache.catalina.startup.Catalina.await(Catalina.java:707)
at org.apache.catalina.startup.Catalina.start(Catalina.java:653)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:29 AM org.apache.coyote.AbstractProtocolHandler pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:10:30 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jan 11, 2013 10:10:30 AM org.apache.coyote.AbstractProtocolHandler stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:30 AM org.apache.coyote.AbstractProtocolHandler stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Now i am getting the following error.
现在我收到以下错误。
Jan 11, 2013 10:18:59 AM 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/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\Jayant\Desktop\data\adt-bundle-windows-x86\eclipse;;.
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:19:00 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 872 ms
Jan 11, 2013 10:19:00 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 11, 2013 10:19:00 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:19:00 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 535 ms
Jan 11, 2013 10:20:13 AM org.apache.catalina.core.StandardServer await
WARNING: StandardServer.await: Invalid command 'GET / HTTP/1.1' received
Jan 11, 2013 10:20:19 AM org.apache.catalina.core.StandardServer await
WARNING: StandardServer.await: Invalid command '' received
回答by Nirav Tukadiya
The admin port is for receiving admin commands,and the HTTP port is for receiving HTTP requests. You must use different ports. What happened is: the HTTP connector could not start, because the server already opened that port. Your browser/client/whatever sent the request to the admin port , the server does not understand HTTP and logs this error.
admin 端口用于接收管理命令,HTTP 端口用于接收 HTTP 请求。您必须使用不同的端口。发生的情况是:HTTP 连接器无法启动,因为服务器已经打开了该端口。您的浏览器/客户端/无论将请求发送到管理端口,服务器都无法识别 HTTP 并记录此错误。
Try Reinstalling Tomcat to another port.
尝试将 Tomcat 重新安装到另一个端口。
回答by Aravind Kumar
Go to server.xml file and change
转到 server.xml 文件并更改
<Server port="8005" shutdown="SHUTDOWN">
to
到
<Server port="8006" shutdown="SHUTDOWN">
Reason for the change is mentioned in one of the post
更改原因在其中一篇文章中提到
回答by pedrobisp
I was having this problem (port 8005 already being used) and the root cause was due to an existing tomcat process already running on my machine. So, what I needed to do was basically kill the existing process and start up tomcat again.
我遇到了这个问题(端口 8005 已经被使用),根本原因是由于现有的 tomcat 进程已经在我的机器上运行。所以,我需要做的基本上是杀死现有进程并再次启动tomcat。
回答by Ammad
use:
用:
pkill -f tomcat
to get rid of any existing or un-responsive tomcat instances or processes.
摆脱任何现有的或无响应的 tomcat 实例或进程。
start tomcat.
回答by ashwin
2 ways to solve this issue:
解决此问题的2种方法:
1> Go the tomcat server installation directory and open the server.xml file, check if the
1>进入tomcat服务器安装目录,打开server.xml文件,检查是否
Connector and server ports are different. If not make them different ports and then check if nothing is run on these ports
连接器和服务器端口不同。如果没有使它们成为不同的端口,然后检查这些端口上是否没有运行任何内容
2> Open command prompt from start and type netstat -ano | findstr 8010 to check if the port are being used. if they are used then you get the TCP 0.0.0.0:8005 0.0.0.0:0 LISTENING 4 TCP [::]:8005 [::]:0 LISTENING 4
2> 从开始打开命令提示符并输入 netstat -ano | findstr 8010 检查端口是否正在使用。如果它们被使用,那么你会得到 TCP 0.0.0.0:8005 0.0.0.0:0 LISTENING 4 TCP [::]:8005 [::]:0 LISTENING 4
then a> kill the process using the process id (4 in my case) from the task manager
然后 a> 使用任务管理器中的进程 ID(在我的情况下为 4)终止进程
If they are not being used then you see nothing in cmd
如果它们没有被使用,那么你在 cmd 中什么也看不到
回答by kenorb
The common mistake is to use the same Shutdown and Connector port in your server.xml
configuration file.
常见的错误是在server.xml
配置文件中使用相同的 Shutdown 和 Connector 端口。
These ports should be different and here is the right example:
这些端口应该不同,这是正确的示例:
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8983" protocol="HTTP/1.1"
By default Tomcat listens on port 8005 for SHUTDOWN command and it should be always different to Connector port.
默认情况下,Tomcat 在端口 8005 上侦听 SHUTDOWN 命令,它应该始终与连接器端口不同。
If your port is still already in use, try sudo lsof -i:8005
for finding why.
如果您的端口仍在使用中,请尝试sudo lsof -i:8005
找出原因。
回答by Biswajit Sahu
If you are using linux system, then type ps -ef|grep tomcat on terminal. Then find the process id(PID). then type kill -9 on the terminal. Now , start the tomcat server.
如果您使用的是 linux 系统,则在终端上输入 ps -ef|grep tomcat。然后找到进程ID(PID)。然后在终端上输入 kill -9 。现在,启动 tomcat 服务器。
回答by Jay Trivedi
What you can do is rather then killing process you can goto tomcat directory/conf/server.xml, Here you can change shutdown port(8005) to some other port. Also change default port (8080) and other to Different one. So you can run several instance of your Tomcat on single Machine. Restart Your Server (if still issue persists) Recreate it in Eclipse.
您可以做的是,而不是杀死进程,您可以转到tomcat目录/conf/server.xml,在这里您可以将关闭端口(8005)更改为其他端口。还将默认端口 (8080) 和其他更改为不同的端口。因此,您可以在一台机器上运行多个 Tomcat 实例。重新启动您的服务器(如果问题仍然存在)在 Eclipse 中重新创建它。