java.net.ConnectException: Connection refused: connect
GoogleCodeExporter opened this issue · comments
What steps will reproduce the problem?
1. deploy hotswap.jar (1.0) and setup the build.xml for ANT (1.6.5)
2. connect to the target jvm_1 (1.6) on localhost, it works
3. connect to another remote jvm_2 (1.6) with Eclipse (3.4.2), it works
4. connect to the the remote jvm_2 (1.6) with hotswap, it doesn't work, and
produces a ConnectException: Connection refused error.
the ANT debug output shows the stacktrace as below
build.xml:339: java.net.ConnectException: Connection refused: connect
at dak.ant.taskdefs.Hotswap.execute(Hotswap.java:221)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:
40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:204)
at
com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.jav
a:98)
at
com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:
72)
at dak.debug.HotSwapHelper.connect(HotSwapHelper.java:83)
at dak.debug.HotSwapHelper.connect(HotSwapHelper.java:36)
at dak.ant.taskdefs.Hotswap.execute(Hotswap.java:193)
... 12 more
--- Nested Exception ---
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:204)
at
com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.jav
a:98)
at
com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:
72)
at dak.debug.HotSwapHelper.connect(HotSwapHelper.java:83)
at dak.debug.HotSwapHelper.connect(HotSwapHelper.java:36)
at dak.ant.taskdefs.Hotswap.execute(Hotswap.java:193)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:
40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Total time: 11 seconds
What is the expected output? What do you see instead?
hotswap should be able to connect to the remote JVM and hotswap classes there.
What version of the product are you using? On what operating system?
hotswap-1.0.zip, on Windows (XP SP2/Vista SP1), JDK 1.6.0_13.
Please provide any additional information below.
I define the hotswap target as below:
<taskdef name="hotswap" classname="dak.ant.taskdefs.Hotswap"/>
<target name="hotswap">
<path id="classpathForJavac"><!-- ... --></path>
<echo message="Compiling: ${filter}.java"/>
<!-- echo message="with classpath = ${toString:classpathForJavac}"/ -->
<javac sourcepath="" srcdir="${product.src.dir};${pm.src.dir}"
destdir="${env.TMP}" debug="on" >
<include name="**/${filter}.java"/>
<classpath refid="classpathForJavac" />
</javac>
<echo message="Hotswapping: ${filter}.class"/>
<hotswap verbose="true" host="${host}" port="1234">
<fileset dir="${env.TMP}" includes="**/${filter}.class" />
</hotswap>
<echo message="hotswap done."/>
</target>
and I'm invoking the ant target like this:
ant hotswap -Dfilter=RequestWrapper -Dhost=10.0.0.105
Original issue reported on code.google.com by roge...@gmail.com
on 9 Apr 2009 at 5:05
I think the current code always connect to localhost (the "host" input parameter
isn't used as far as I know), so you may try hotswap on a local JVM
Original comment by endermoo...@gmail.com
on 20 Nov 2009 at 11:52
I'd the same problem, and check your java launch options:
-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n
For example, in eclipse debug, it's launched like -Xdebug
-Xrunjdwp:transport=dt_socket,address=9000,server=n,suspend=y
You need server=y, for do hotswap.
Original comment by pablo.pa...@gmail.com
on 26 Nov 2009 at 10:09
Hotswap does not close its debugger connection, so in Eclipse, after your 1st
hotswap works, your 2nd will not - unless the containing Ant process ends.
I fixed this by changing my Ant task to run under an Execution Environment
instead of "same JRE as the workspace". Once the hotswap is done, the hotswap
process dies and the client socket is closed, allowing the server socket to
accept a new debug connection.
Original comment by glen.a.l...@gmail.com
on 31 Aug 2011 at 6:54
The last problem reported is resolved adding the next code in HotSwapHelper
class:
public void disconnect() throws Exception {
// close the communication channel to the target VM
vm.dispose();
}
Original comment by Joaquin....@gmail.com
on 14 Mar 2012 at 3:47
[deleted comment]
The problem reported in Comment 1 ("the current code always connect to
localhost") is solved by next steps:
(1) edit HotSwapHelper class and method:
private void connect(String host, String port, String name)
(2) search the next lines:
arg = (Connector.Argument)args.get("port");
arg.setValue(port);
(3) before these lines, put:
arg = (Connector.Argument)args.get("hostname");
arg.setValue(host);
Original comment by Joaquin....@gmail.com
on 14 Mar 2012 at 4:11
[deleted comment]
SSH -L <port>:<youhost>:<port> user@remoutehost
after this command try connect to localhost
must help.
Original comment by sergeyse...@gmail.com
on 1 Feb 2015 at 1:46