拒绝使用Tomcat连接进行Netbeans调试

时间:2018-01-26 19:21:11

标签: java tomcat netbeans

我使用的是Netbeans 8.2,安装了Java EE Base 1.31.1和EJB和EAR 1.27.1插件。我安装了Tomcat 9.0.4并将其作为服务器添加到Netbeans中。 Netbeans可以成功启动tomcat服务器并启动我的Web应用程序,但它不会调试。当我尝试调试我的webapp时,我的webapp日志中出现以下错误:

ant -f /Users/jryan/JDev/SVN/trunk/Java/CollaborationServer -Dnb.internal.action.name=debug -Ddirectory.deployment.supported=true -DforceRedeploy=false -Dnb.wait.for.caches=true -Dbrowser.context=/Users/jryan/JDev/SVN/trunk/Java/CollaborationServer debug
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
debug:
Stopping Tomcat process...
Waiting for Tomcat...
Tomcat server stopped.
Starting Tomcat process...
Waiting for Tomcat...
Tomcat server started.
connect-debugger:
/Users/jryan/JDev/SVN/trunk/Java/CollaborationServer/nbproject/build-impl.xml:1206: The following error occurred while executing this line:
/Users/jryan/JDev/SVN/trunk/Java/CollaborationServer/nbproject/build-impl.xml:1216: 
org.netbeans.api.debugger.jpda.DebuggerStartException: Connection refused (Connection refused)
    at org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.waitRunning(JPDADebuggerImpl.java:405)
    at org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.waitRunning(JPDADebuggerImpl.java:387)
    at org.netbeans.api.debugger.jpda.JPDADebugger.attach(JPDADebugger.java:324)
    at org.netbeans.modules.debugger.jpda.ant.JPDAConnect$1.run(JPDAConnect.java:235)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:222)
    at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
    at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
    at org.netbeans.api.debugger.jpda.AttachingDICookie.getVirtualMachine(AttachingDICookie.java:231)
    at org.netbeans.modules.debugger.jpda.actions.StartActionProvider.doStartDebugger(StartActionProvider.java:188)
    at org.netbeans.modules.debugger.jpda.actions.StartActionProvider.access$200(StartActionProvider.java:80)
    at org.netbeans.modules.debugger.jpda.actions.StartActionProvider$1.run(StartActionProvider.java:165)
    ... 4 more
BUILD FAILED (total time: 7 seconds)

tomcat日志显示Listening for transport dt_socket at address: 8000

Netbeans调试器控制台说:

Attaching to localhost:8000
Connection refused.

有谁知道这里发生了什么,我能做些什么来解决它?

谢谢!

2 个答案:

答案 0 :(得分:0)

也许尝试添加此Answer中详述的标记。

这就是我们目前的做法。

答案 1 :(得分:0)

糟糕。事实证明,我在/ etc / hosts文件中注释了127.0.0.1 localhost条目。当我重新启用localhost时,它工作正常!另外,我认为我必须注释掉默认的localhost行,因为我在那里测试了一个本地托管站点的另一行,但根据this回答,没有必要这样做! / p>