部署错误:Tomcat启动失败,服务器端口8080已经在使用

时间:2021-03-18 20:07:57

When i run my java project using netbeans i get the following error:

当我使用netbeans运行我的java项目时,我得到以下错误:

Deployment error:
Starting of Tomcat failed, the server port 8080 is already in use.
See the server log for details.
        at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
        at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor619.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: org.netbeans.modules.j2ee.deployment.impl.ServerException: Starting of Tomcat failed, the server port 8080 is already in use.
        at org.netbeans.modules.j2ee.deployment.impl.ServerInstance._start(ServerInstance.java:1297)
        at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1251)
        at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1062)
        at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.start(ServerInstance.java:939)
        at org.netbeans.modules.j2ee.deployment.impl.TargetServer.startTargets(TargetServer.java:428)
        at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:143)
        ... 16 more
BUILD FAILED (total time: 4 seconds)

I tried changing the server port to 8081 and shutdown port in tool->server, It runs fine but again if i do any operations and run the project it says "Deployment error:Starting of Tomcat failed, the server port 8081 is already in use" What would be the problem can any one help me.

我试着改变服务器端口8081和关闭端口工具- >服务器,它运行很好但是如果我做任何操作和运行项目说“部署错误:启动Tomcat的失败,服务器端口8081已经在使用了“什么是任何一个能帮助我的问题。

14 个解决方案

#1


97  

goto command prompt

转到命令提示符

netstat -aon

for linux

linux

netstat -tulpn | grep 'your_port_number'

it will show you something like

它会给你一些类似的东西。

 TCP    192.1.200.48:2053      24.43.246.60:443       ESTABLISHED     248
 TCP    192.1.200.48:2055      24.43.246.60:443       ESTABLISHED     248
 TCP    192.1.200.48:2126      213.146.189.201:12350  ESTABLISHED     1308
 TCP    192.1.200.48:3918      192.1.200.2:8073       ESTABLISHED     1504
 TCP    192.1.200.48:3975      192.1.200.11:49892     TIME_WAIT       0
 TCP    192.1.200.48:3976      192.1.200.11:49892     TIME_WAIT       0
 TCP    192.1.200.48:4039      209.85.153.100:80      ESTABLISHED     248
 TCP    192.1.200.48:8080      209.85.153.100:80      ESTABLISHED     248

check which process has binded your port. here in above example its 248 now if you are sure that you need to kill that process fire

检查哪个进程绑定了您的端口。在上面的例子中,如果你确定你需要杀死这个过程的火焰,它的248。

Linux:

Linux:

kill -9 248

Windows:

窗口:

taskkill /f /pid 248

it will kill that process

它会扼杀这个过程

#2


7  

If you are behind a proxy server this issue could happen i had the same issue and was solved by: Preferences -> General -> Proxy Settings -> No Proxy.

如果您在代理服务器后面,那么这个问题可能会发生,我遇到了相同的问题,通过:Preferences -> General -> proxy Settings -> No proxy来解决。

"Maybe the tomcat ready-message was sent to the proxy - and never reached the IDE."

“可能tomcat的现成消息被发送到代理——而且从未到达IDE。”

found @: https://netbeans.org/bugzilla/show_bug.cgi?id=231220

@:https://netbeans.org/bugzilla/show_bug.cgi?id=231220中找到

#3


6  

I had the same problem when trying to deploy, tomcat failed to restart as Tomcat instance was running. Close the IDE and check TASk Manager - kill any javaw process running, that solved the problem for me.

我在尝试部署时遇到了同样的问题,tomcat在运行tomcat实例时未能重新启动。关闭IDE并检查任务管理器——杀死任何正在运行的javaw进程,解决了我的问题。

#4


4  

Take a look on your running processes, it seems like your current Tomcat instance did not stop. It's still running and NetBeans tries to start a second Tomcat-instance. Thats the reason for your exception, you just have to stop the first instance, or deploy you code on the current running one

查看一下正在运行的进程,您当前的Tomcat实例似乎没有停止。它仍在运行,NetBeans试图启动第二个tomcat实例。这就是您出现异常的原因,您只需停止第一个实例,或者在当前正在运行的实例上部署代码

#5


4  

By changing proxy settings to "no proxy" in netbeans the tomcat prbolem got solved.Try this it's seriously working.

通过将netbeans中的代理设置更改为“无代理”,tomcat prbolem得到了解决。试试这个,它确实有效。

#6


3  

If on Linux you can kill existing Tomcats with this script

如果在Linux上,您可以使用这个脚本杀死现有的Tomcats

#/bin/bash
if [ `whoami` != root ]; then
    echo "Please run this script as root or using sudo"
    exit
fi
echo
echo "finding proceses that have name java and established connections status"
echo
echo "Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name"
netstat --tcp  --programs  | grep "ESTABLISHED" | grep "java"
echo
echo "finding proceses that use port 8080 or http-alt"
echo
netstat --tcp --programs | grep ':8080\|:http-alt'
echo -n "Do you wish to kill a process listed above?[Y/n]"
read choose
if [ "$choose" = "Y" ] || [ "$choose" = "y" ] || [ -z "$choose" ]
then
echo "enter pid to kill"
read procesId
kill -9 $procesId
fi
echo "done exiting"
exit 0

#7


2  

Kill the previous instance of tomcat or the process that's running on 8080.

杀死tomcat的前一个实例或在8080上运行的进程。

Go to terminal and do this:

到终端,这样做:

lsof -i :8080

lsof我:8080

The output will be something like:

输出如下:

COMMAND   PID   USER      FD   TYPE  DEVICE SIZE/OFF NODE NAME
java    76746   YourName  57u  IPv6 0xd2a83c9c1e75      0t0    TCP *:http-alt (LISTEN)

Kill this process using it's PID:

用它的PID杀死这个过程:

kill 76746

76746年杀

#8


1  

Select the project -> Right-Click -> clean and build and then run the project again simply solve the problem for me.

选择项目->右键单击->清理并构建,然后再次运行项目,为我简单地解决问题。

As, multiple process could bind the same port for example port 8086, In that case I have to kill all the processes involved with the port with PID. That might be cumbersome.

因为,多个进程可以绑定相同的端口,例如端口8086,在这种情况下,我必须使用PID终止与端口相关的所有进程。这可能是麻烦。

#9


0  

I had a similar issue, except it was port 80 that was already in use. It turned out to be Microsofts IIS services. I dont use them at all so just uninstalled them through appwiz.cpl.

我也遇到了类似的问题,除了已经在使用的端口80。原来是微软的IIS服务。我根本不用它们,只是通过appwiz.cpl卸载它们。

#10


0  

In my case I accidentally added two instances of server and got this error.. Just take a look in Services tab under Servers and remove one of the instance... and restart the server... :)

在我的例子中,我不小心添加了两个服务器实例,得到了这个错误。只需查看服务器下的Services选项卡,并删除其中一个实例……并重新启动服务器……:)

#11


0  

Change your default port in [tomcat_home_dir]/conf/server.xml find

在[tomcat_home_dir]/conf/服务器中更改默认端口。xml找到

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

change it to

将其更改为

<Connector port="8090" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

#12


0  

Change your Tomcat port address to 8084 and Shut Down Port to 8025. This will resolve your problem.

将Tomcat端口地址更改为8084,并将端口关闭为8025。这将解决你的问题。

In other cases antivirus programs may cause problems. I had this problem with K7 total security. In my case K7 Firewall was blocking the 8084 port. The simple solution is to add an exception to Netbeans in K7 Firewall list.

在其他情况下,反病毒程序可能会引起问题。K7的总安全性有问题。在我的例子中,K7防火墙阻塞了8084端口。简单的解决方案是在K7防火墙列表中向Netbeans添加一个异常。

In order to do that, open K7 and goto Settings -> Firewall Settings -> select Applications tab and find Netbeans.

为此,打开K7和goto设置—>防火墙设置—>选择应用程序选项卡并找到Netbeans。

Select Netbeans and click on edit link. On next screen select Grant Full Network access radio button.

选择Netbeans并单击edit链接。在下一个屏幕上选择Grant Full Network access单选按钮。

Now goto Netbeans and start the server.

现在转到Netbeans并启动服务器。

#13


-1  

I have fixed this, in Windows 8.1 x64.

我已经在Windows 8.1 x64中解决了这个问题。

  1. goto - %userprofile%\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\work\Catalina\localhost
  2. goto - % userprofile % \ AppData \漫游\ NetBeans \ 8.1 \ apache-tomcat-8.0.27.0_base \ \卡特琳娜\ localhost
  3. Delete all folder without (manager and ROOT) folders
  4. 删除所有文件夹没有(管理器和根)文件夹
  5. goto - %userprofile%\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\conf\Catalina\localhost
  6. goto - % userprofile % \ AppData \漫游\ NetBeans \ 8.1 \ apache-tomcat-8.0.27.0_base \ conf \卡特琳娜\ localhost
  7. delete all files without (manager.xml and ROOT.xml)
  8. 删除所有文件没有(管理器。xml和ROOT.xml)
  9. goto NetBeans and Start Tomcat server
  10. 访问NetBeans并启动Tomcat服务器

#14


-1  

Steps:

步骤:

  • 1) open your Netbeans .
  • 1)打开你的Netbeans。
  • 2) Go to tools.
  • 2)工具。
  • 3) Go to servers.
  • 3)服务器。
  • 4) Now change your port no. and shut down port no. most probably you should increase both by 1 . eg 8084 to 8085 and the shut down port no 8025 to 8026
  • 现在改变你的港口。关闭港口。很可能你应该同时增加1。8084到8085,关闭端口8025到8026
  • 5) Restart you Netbeans and try to run your project. Problem solved
  • 5)重新启动Netbeans并尝试运行项目。问题解决了

#1


97  

goto command prompt

转到命令提示符

netstat -aon

for linux

linux

netstat -tulpn | grep 'your_port_number'

it will show you something like

它会给你一些类似的东西。

 TCP    192.1.200.48:2053      24.43.246.60:443       ESTABLISHED     248
 TCP    192.1.200.48:2055      24.43.246.60:443       ESTABLISHED     248
 TCP    192.1.200.48:2126      213.146.189.201:12350  ESTABLISHED     1308
 TCP    192.1.200.48:3918      192.1.200.2:8073       ESTABLISHED     1504
 TCP    192.1.200.48:3975      192.1.200.11:49892     TIME_WAIT       0
 TCP    192.1.200.48:3976      192.1.200.11:49892     TIME_WAIT       0
 TCP    192.1.200.48:4039      209.85.153.100:80      ESTABLISHED     248
 TCP    192.1.200.48:8080      209.85.153.100:80      ESTABLISHED     248

check which process has binded your port. here in above example its 248 now if you are sure that you need to kill that process fire

检查哪个进程绑定了您的端口。在上面的例子中,如果你确定你需要杀死这个过程的火焰,它的248。

Linux:

Linux:

kill -9 248

Windows:

窗口:

taskkill /f /pid 248

it will kill that process

它会扼杀这个过程

#2


7  

If you are behind a proxy server this issue could happen i had the same issue and was solved by: Preferences -> General -> Proxy Settings -> No Proxy.

如果您在代理服务器后面,那么这个问题可能会发生,我遇到了相同的问题,通过:Preferences -> General -> proxy Settings -> No proxy来解决。

"Maybe the tomcat ready-message was sent to the proxy - and never reached the IDE."

“可能tomcat的现成消息被发送到代理——而且从未到达IDE。”

found @: https://netbeans.org/bugzilla/show_bug.cgi?id=231220

@:https://netbeans.org/bugzilla/show_bug.cgi?id=231220中找到

#3


6  

I had the same problem when trying to deploy, tomcat failed to restart as Tomcat instance was running. Close the IDE and check TASk Manager - kill any javaw process running, that solved the problem for me.

我在尝试部署时遇到了同样的问题,tomcat在运行tomcat实例时未能重新启动。关闭IDE并检查任务管理器——杀死任何正在运行的javaw进程,解决了我的问题。

#4


4  

Take a look on your running processes, it seems like your current Tomcat instance did not stop. It's still running and NetBeans tries to start a second Tomcat-instance. Thats the reason for your exception, you just have to stop the first instance, or deploy you code on the current running one

查看一下正在运行的进程,您当前的Tomcat实例似乎没有停止。它仍在运行,NetBeans试图启动第二个tomcat实例。这就是您出现异常的原因,您只需停止第一个实例,或者在当前正在运行的实例上部署代码

#5


4  

By changing proxy settings to "no proxy" in netbeans the tomcat prbolem got solved.Try this it's seriously working.

通过将netbeans中的代理设置更改为“无代理”,tomcat prbolem得到了解决。试试这个,它确实有效。

#6


3  

If on Linux you can kill existing Tomcats with this script

如果在Linux上,您可以使用这个脚本杀死现有的Tomcats

#/bin/bash
if [ `whoami` != root ]; then
    echo "Please run this script as root or using sudo"
    exit
fi
echo
echo "finding proceses that have name java and established connections status"
echo
echo "Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name"
netstat --tcp  --programs  | grep "ESTABLISHED" | grep "java"
echo
echo "finding proceses that use port 8080 or http-alt"
echo
netstat --tcp --programs | grep ':8080\|:http-alt'
echo -n "Do you wish to kill a process listed above?[Y/n]"
read choose
if [ "$choose" = "Y" ] || [ "$choose" = "y" ] || [ -z "$choose" ]
then
echo "enter pid to kill"
read procesId
kill -9 $procesId
fi
echo "done exiting"
exit 0

#7


2  

Kill the previous instance of tomcat or the process that's running on 8080.

杀死tomcat的前一个实例或在8080上运行的进程。

Go to terminal and do this:

到终端,这样做:

lsof -i :8080

lsof我:8080

The output will be something like:

输出如下:

COMMAND   PID   USER      FD   TYPE  DEVICE SIZE/OFF NODE NAME
java    76746   YourName  57u  IPv6 0xd2a83c9c1e75      0t0    TCP *:http-alt (LISTEN)

Kill this process using it's PID:

用它的PID杀死这个过程:

kill 76746

76746年杀

#8


1  

Select the project -> Right-Click -> clean and build and then run the project again simply solve the problem for me.

选择项目->右键单击->清理并构建,然后再次运行项目,为我简单地解决问题。

As, multiple process could bind the same port for example port 8086, In that case I have to kill all the processes involved with the port with PID. That might be cumbersome.

因为,多个进程可以绑定相同的端口,例如端口8086,在这种情况下,我必须使用PID终止与端口相关的所有进程。这可能是麻烦。

#9


0  

I had a similar issue, except it was port 80 that was already in use. It turned out to be Microsofts IIS services. I dont use them at all so just uninstalled them through appwiz.cpl.

我也遇到了类似的问题,除了已经在使用的端口80。原来是微软的IIS服务。我根本不用它们,只是通过appwiz.cpl卸载它们。

#10


0  

In my case I accidentally added two instances of server and got this error.. Just take a look in Services tab under Servers and remove one of the instance... and restart the server... :)

在我的例子中,我不小心添加了两个服务器实例,得到了这个错误。只需查看服务器下的Services选项卡,并删除其中一个实例……并重新启动服务器……:)

#11


0  

Change your default port in [tomcat_home_dir]/conf/server.xml find

在[tomcat_home_dir]/conf/服务器中更改默认端口。xml找到

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

change it to

将其更改为

<Connector port="8090" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

#12


0  

Change your Tomcat port address to 8084 and Shut Down Port to 8025. This will resolve your problem.

将Tomcat端口地址更改为8084,并将端口关闭为8025。这将解决你的问题。

In other cases antivirus programs may cause problems. I had this problem with K7 total security. In my case K7 Firewall was blocking the 8084 port. The simple solution is to add an exception to Netbeans in K7 Firewall list.

在其他情况下,反病毒程序可能会引起问题。K7的总安全性有问题。在我的例子中,K7防火墙阻塞了8084端口。简单的解决方案是在K7防火墙列表中向Netbeans添加一个异常。

In order to do that, open K7 and goto Settings -> Firewall Settings -> select Applications tab and find Netbeans.

为此,打开K7和goto设置—>防火墙设置—>选择应用程序选项卡并找到Netbeans。

Select Netbeans and click on edit link. On next screen select Grant Full Network access radio button.

选择Netbeans并单击edit链接。在下一个屏幕上选择Grant Full Network access单选按钮。

Now goto Netbeans and start the server.

现在转到Netbeans并启动服务器。

#13


-1  

I have fixed this, in Windows 8.1 x64.

我已经在Windows 8.1 x64中解决了这个问题。

  1. goto - %userprofile%\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\work\Catalina\localhost
  2. goto - % userprofile % \ AppData \漫游\ NetBeans \ 8.1 \ apache-tomcat-8.0.27.0_base \ \卡特琳娜\ localhost
  3. Delete all folder without (manager and ROOT) folders
  4. 删除所有文件夹没有(管理器和根)文件夹
  5. goto - %userprofile%\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\conf\Catalina\localhost
  6. goto - % userprofile % \ AppData \漫游\ NetBeans \ 8.1 \ apache-tomcat-8.0.27.0_base \ conf \卡特琳娜\ localhost
  7. delete all files without (manager.xml and ROOT.xml)
  8. 删除所有文件没有(管理器。xml和ROOT.xml)
  9. goto NetBeans and Start Tomcat server
  10. 访问NetBeans并启动Tomcat服务器

#14


-1  

Steps:

步骤:

  • 1) open your Netbeans .
  • 1)打开你的Netbeans。
  • 2) Go to tools.
  • 2)工具。
  • 3) Go to servers.
  • 3)服务器。
  • 4) Now change your port no. and shut down port no. most probably you should increase both by 1 . eg 8084 to 8085 and the shut down port no 8025 to 8026
  • 现在改变你的港口。关闭港口。很可能你应该同时增加1。8084到8085,关闭端口8025到8026
  • 5) Restart you Netbeans and try to run your project. Problem solved
  • 5)重新启动Netbeans并尝试运行项目。问题解决了