Netbeans Debugging with Tomcat Connection Refused - java

I am using Netbeans 8.2 with the Java EE Base 1.31.1 and EJB and EAR 1.27.1 plugins installed. I installed Tomcat 9.0.4 and added it as a server to Netbeans. Netbeans can successfully start the tomcat server and launch my web app, but it will not debug. When I attempt to debug my webapp, I get the following error in my webapp log:
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)
The tomcat log says Listening for transport dt_socket at address: 8000
And the Netbeans Debugger Console says:
Attaching to localhost:8000
Connection refused.
Does anyone know what is happening here, and what I can do to fix it?
Thanks!

Perhaps try adding the flags detailed in this Answer.
This is how we currently do it.

Oops. It turns out that I had commented out the 127.0.0.1 localhost entry in my /etc/hosts file. When I re-enabled localhost, it worked fine! And as an aside, I thought I had to comment out the default localhost line because I had another line in there for a locally hosted site I was testing, but according to this answer, there's no need to do that!

Related

Connection refused occured when I trying to connect to Redis that run in Docker in WSL2 (Ubuntu 18.04)

Never happened before, but today I upgrade Windows preview version, and an exception occured (Connection Refused: connect).
Redis runs in a Docker container and Docker runs in WSL2 (Ubuntu 18.04), and also there are a Mongodb database and a Mysql database running in docker.
I cannot connect to Mongodb(by Java) or Redis (by Jedit) but Mysql is well (by Navicat or Java).
Then, I write a simple java program with Jedis to connect to Redis, it works failed in Windows but successful in WSL2. And I also connect to Redis with telnet command, it works successful in Windows and WSL2.
Windows Version: 10.0.20175.1000, Insider Preview, Build 20175.re_prerelease.200717-1349
Linux in WSL2: Ubuntu 18.04
Docker Version: 19.03.8
Mongodb and Redis: latest
Mysql: 5.6
Jedis: 2.7.2
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
at redis.clients.jedis.Connection.connect(Connection.java:155)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:83)
at redis.clients.jedis.Connection.sendCommand(Connection.java:94)
at redis.clients.jedis.BinaryClient.set(BinaryClient.java:100)
at redis.clients.jedis.Client.set(Client.java:29)
at redis.clients.jedis.Jedis.set(Jedis.java:65)
at com.ty.tissue.config.TissueConfig.main(TissueConfig.java:105)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
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.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at redis.clients.jedis.Connection.connect(Connection.java:149)
... 6 more
help me, thanks.

How can I do remote debugging with my tomcat server running on an VM in IntelliJ community Edition?

I want to remote debug an application. My tomcat server is running in a Vm. I am trying to connect to it to debug. How can I connect to it?
NOTE: I am trying to do this in windows machines.
Already tried the solution mentioned in.
How to debug a Tomcat 7.x/8.x webapp locally with IntelliJ Community (free) version in Linux?. But after following the steps, I am getting:
Error running 'Local Apache Tomcat': Unable to open debugger port (localhost:12000): java.net.ConnectException "Connection refused: connect"
Error running 'Local Apache Tomcat': Unable to open debugger port (10.194.43.79:12000): java.net.ConnectException "Connection refused: connect"
Made sure the jdk that I am mentioning in settings. And the one which is installed in vm machine, It's same.
I am able to ping the machine.
I've tried to connect to it with tomcat which is running on my machine. It's not working.
Acc. to How to debug a Tomcat 7.x/8.x webapp locally with IntelliJ Community (free) version in Linux?
I should've received:
Connected to the target VM, address: '10.194.43.79:12000', transport: 'socket'
Instead it's:
Error running 'Local Apache Tomcat': Unable to open debugger port (10.194.43.37:12000): java.net.ConnectException "Connection timed out: connect"

Problems starting zookeeper

I face a strange problem while starting zookeeper. Everytime I start zookeeper, it is getting started but it is getting bound to the port as a process that I am able to restart it again. Following is my zoo.cfg file
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/var/zookeeper
clientPort=2181
Also when I try connecting and executing zoo keeper commands through my java file, I get the below error
15/07/20 12:27:46 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
15/07/20 12:27:46 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
java.lang.RuntimeException: error in updating node :/testnode/test result : CONNECTION_LOSS
So can someone explain me why is it trying to re-connect and help me sort this error out ?
This occurred because my java home was not exported correctly. It was pointed to the bin inside jdk directory which should not be the case. So after exporting java home to the root directory of jdk solved the issue

eclipse and tomcat debugging

While trying to configure eclipse, tomcat to debug a maven project I am getting the following error:
Failed to connect to remote VM. Connection refused.
Connection refused
What am i doing wrong?
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:136)
at java.lang.Thread.run(Thread.java:680)
This basically means eclipse can't connect to the target tomcat. This may be due to tons of reasons:
tomcat isn't started
tomcat isn't accessible over the network
the debug port is not accessible (check firewall)
tomcat isn't configured to accept debugging (it should have something like the following in the startup script -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n)

Cassandra -- nodetool is not working on another machine?

I have a cassandra cluster on 4 nodes (each running ubuntu 10.04 and cassandra 0.7.4).
All nodes are connected using a SWITCH, and each is assigned a STATIC IP ADDRESS (no DNS is involved).
The node seems to be functioning properly (status is 'Normal', all nodes are up etc).
The problem is this: nodetool works, yet it only works when the nodetool command is run on the same node. When I try to run nodetool from STATIC_IP = 192.168.0.253 on STATIC_IP = 192.168.0.4 I get the following error:
(note: machine 's3789' has the static IP of 192.168.0.253)
user#s3789:/opt/cassandra/apache-cassandra-0.7.4$ bin/nodetool -host 192.168.0.4 ring
Error connection to remote JMX agent!
java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:128)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2343)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:296)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267)
at org.apache.cassandra.tools.NodeProbe.connect(NodeProbe.java:137)
at org.apache.cassandra.tools.NodeProbe.<init>(NodeProbe.java:107)
at org.apache.cassandra.tools.NodeCmd.main(NodeCmd.java:511)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at java.net.Socket.<init>(Socket.java:392)
at java.net.Socket.<init>(Socket.java:206)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
Any hints how to solve this?
from conf/cassandra-env.sh:
# add this if you're having trouble connecting:
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
#
# see
# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
# for more on configuring JMX through firewalls, etc. (Short version:
# get it working with no firewall first.)
Check if you started rmiregistry before starting the server
rmiregistry &
Getting started with RMI

Categories