views:

405

answers:

3

I'm running some JUnit 4 tests in eclipse for my Java project which I know have functioned two days ago without problems.

Today, though, I get errors:

Could not connect to:  : 40212    
java.net.SocketException: Network is unreachable
    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:525)
    at java.net.Socket.connect(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:372)
    at java.net.Socket.<init>(Socket.java:186)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.connect(RemoteTestRunner.java:570)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:381)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Neither the test nor the code do something with networks.

Also the eclipse dialog for installing new software can't connect to the update sites and neither can the SVN plug-in connect to the repository. The SVN repository is reachable, I've checked with the cli-svn program. Proxies in eclipse are disabled.

So my question is, why does JUnit want to connect to the internet in the first place (how should offline working even be possible..) and can I do something to find the source of the problems? (My plan B is to remove eclipse and re-install it again)

A: 

Have you tried looking at the "Run Configurations" for the test that you're trying to execute? (i.e. right click the test and choose "Run As > Run Configurations") Perhaps there are some settings that have gone a little haywire. Perhaps there is something mis-configured with the "Test runner" setting in the "Test" tab?

digiarnie
+3  A: 

I suspect Junit is launched as a separate process on the same machine (note the references to RemoteTestRunner above), and then Eclipse will talk to it via a socket.

So is there some issue related to your TCP stack on your machine. Are you out of networking resources ? Is something hogging these ?

netstat may be of use here. Or maybe a simple reboot ?

Brian Agnew
I couldn't solve the problem, I tried using another eclipse installation, I removed and re-installed some Java packages, tried different workspaces, but nothing helped. I now use eclipse on a virtual machine (it's ugly I know, but I need to get some work done). You did answer my question about why is it using network, though.
Schtibe
I suffered from the same problem today. Are you by any chance using Debian? If so, then this is related to bugs http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560238 and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560056 and can be fixed by setting net.ipv6.bindv6only=1 in /etc/sysctl.d/bindv6only.conf
Confusion
inger
+1  A: 

The answer to the question "why would Eclipse want to connect to the internet" is that Eclipse doesn't connect to the internet at all, however Eclipse has a special JUnit test listener which communicates with the JVM running the JUnit tests. This test listener opens up a socket on localhost (I'm not 100% sure on which side the server-socket is, but that probably doesn't matter).

I think that you have some networking trouble on your end preventing the Eclipse process from opening a socket on localhost. I've experienced similar trouble after bringing up/down a VPN and after coming back from a suspend/resume cycle.

I'd try a reboot first. If that doesn't work, I'd try running from a different workspace (run .../eclipse.exe -data path/to/new/workspace). Remember that there is no point in uninstalling Eclipse. Just unpack a new Eclipse somewhere and try running from there instead.

JesperE
+1 for the hints. You could be right about the suspend/resume cycle. I just don't have time to put more effort in this, see my comment above.
Schtibe
If you do find out what's causing this, I'd be interested to hear about it.
JesperE