views:

1406

answers:

4

I and my colleagues have an intermittent problem running junit tests or tomcat from within Eclipse.

Sometimes the tests will run. Sometimes they will not. There appears to be no pattern and we are not in sync. IE mine might run and others will fail.

Stopping/starting Eclipse can resolve the issue (sometimes). Pulling out the network cable ALWAYS resolves the problem (while it is out).

When it fails the following happens. On trying to run the class the Console screen appears with the red box. The console screen stays blank for about 30 seconds and then the following appears:

Could not connect to: : 2083 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:520) at java.net.Socket.connect(Socket.java:470) at java.net.Socket.(Socket.java:367) at java.net.Socket.(Socket.java:180) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.connect(RemoteTestRunner.java:560) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:377) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

The port number varies. I found a forum post that told me follow this http://support.microsoft.com/kb/135982 But this did not work.

We are all on Microsoft XP based machines connecting to the internet via an ISA server/proxy. I am running Eclipse 3.3.3 and MyEclipse 6.0.1

Any ideas please ?

A: 

Some suggestions...:

Did you look at tomcat logs ?

Do you see in them some ClientAbortException: java.net.SocketException: Broken pipe. ?

It looks like the server thinks the client is closing the connection at times. And like the client is getting the connection reset by the server (connection reset), and the server is not listening sometimes (connection refused).

If you are testing from behind a firewall/proxy server, you may need to provide TomCat with the firewall/proxy server hostname and port number.

Restarting eclipse should be enough:

Apparently the JUnit runner thread in Eclipse attaches to an Eclipse server thread to run the tests. It would seem the client thread was trying to connect to the wrong port (3393) or that the server thread that had been listening on port 3393 for runtime requests failed.

The solution McQueeney found is here (thank you Archive.org!)

One suggestion I find interesting is:

I had to change the jre that my Eclipse project uses to make sure that JUnit and my project were using the same jre. After a restart of Eclipse the error was gone.

I hope you will find a definitive cause for this.

VonC
A: 

I had the same problem, when my network driver was broken.

JUnit und Eclipse communicate via ICP (InterProcess Communication), better said: via TCP. To run it successfully, you have repair your network drivers.

Try to reinstall TCP/IP protocols or turn it back to a system restore point.

Good luck!

furtelwart
+1  A: 

I have concentrated on junit instead of tomcat as it is much quicker & easier to reproduce. Yep I had seen the McQueeney link with no luck.

We have done some more digging and interestingly when you run junit from Eclipse, Eclipse decides to go & check for updates, Yes that's right - everytime you run a junit (& I guess tomcat and others).

We removed a colleague's access restrictions to the WWW through the ISA server and low & behold the problem disappeared.

We are still monitoring this to see if it is the solution. Watch this space.

I have tried looking through the Eclipse set up to see if I can stop it trundling off everytime to the WWW but have not seen a suitable option yet.

Bill Comer
Could you please paste this information into your start question? It would increase readability. Thanks!
furtelwart
A: 

So your JUnit only works, if there's a connection to the internet? Or was it a one time action and now, it works without an internet connection?

Strange world... Are there any hints in a log file?

furtelwart