Sbt 0.13.2 Fork Tests : Could not accept connection from test agent: SocketException: Socket closed

1,850 views
Skip to first unread message

Luchesar Cekov

unread,
May 27, 2014, 8:12:56 AM5/27/14
to sbt...@googlegroups.com

I would like to run my play framework tests in parallel in many forked JVMs so I've got:

 fork in test := true

When I add that setting running the tests ends up with:

[error] Could not accept connection from test agent: class java.net.SocketException: Socket closed
[trace] Stack trace suppressed: run last test:test for the full output.
[trace] Stack trace suppressed: run last test:executeTests for the full output.
[error] (test:executeTests) java.lang.NullPointerException

And the details:

$ last test:testOnly
[debug] Forking tests - parallelism = false
[error] Could not accept connection from test agent: class java.net.SocketException: Socket closed
java.net.SocketException: Socket closed
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)
at java.net.ServerSocket.implAccept(ServerSocket.java:530)
at java.net.ServerSocket.accept(ServerSocket.java:498)
at sbt.ForkTests$$anonfun$mainTestTask$1$Acceptor$2$.run(ForkTests.scala:48)
at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1010)
at sbt.SimpleProcessBuilder.run(ProcessImpl.scala:388)
at sbt.AbstractProcessBuilder.run(ProcessImpl.scala:138)
at sbt.Fork.fork(Fork.scala:97)
at sbt.Fork.apply(Fork.scala:75)
at sbt.ForkTests$$anonfun$mainTestTask$1.apply(ForkTests.scala:90)
at sbt.ForkTests$$anonfun$mainTestTask$1.apply(ForkTests.scala:34)
at sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:45)
at sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:45)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Is that an Sbt problem or I am doing something wrong. There is nothing about it when I search the web.

Many thanks,
Lucho

Josh Suereth

unread,
May 27, 2014, 8:42:21 AM5/27/14
to sbt...@googlegroups.com
Is this new in sbt 0.13.2 vs. 0.13.1?

It looks kind of like one of two things:

1. You are unable to fork the underlying process
2. Your firewall is preventing communication over a socket to the sbt parent process.


--
You received this message because you are subscribed to the Google Groups "sbt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sbt-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sbt-dev/0be0949c-9fc2-4581-a236-e59b1766282d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luchesar Cekov

unread,
May 27, 2014, 9:07:26 AM5/27/14
to sbt...@googlegroups.com
I don't think its new in 0.13.2

I am trying to run the tests in parallel for the first time. I tried it out with 0.13.5-RC5, 0.13.1 and 0.13.0 with the same result though.

I don't really have a firewall on my linux laptop.

What do you mean with I am unable to fork the underlying process? If you look at the stack trace there is NullPointerException before anything is being forked. The exception is at java.lang.ProcessBuilder.start(ProcessBuilder.java:1010)

I am running java 1.7.0_55 and if you open up the ProcessBuilder class you will see that this exception is thrown if one of the elements in the argument list is null. This means sbt is passing some null arguments to the process builder.

This might be a misconfiguration from mi site which I am unable to spot or a bug in SBT. I am posting here to find out if it is the first one before I fill in an issue in http://github.com/sbt/sbt

Any ideas what might be causing the null element in the argument list?

Josh Suereth

unread,
May 27, 2014, 9:15:13 AM5/27/14
to sbt...@googlegroups.com
Unfortunately, checking the fork options isn't directly exposed cleanly.   "show test:run::runner" is the closes you can get to see what we're passing.


Additionally, you can use a REPL against it with the following:

```
$ sbt
>  consoleProject
scala>  val runner = (runner in (Test, run)).eval
scala> runner.<something you want to try>
```


Let us know if you can get some more information out.



--
You received this message because you are subscribed to the Google Groups "sbt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sbt-dev+u...@googlegroups.com.

Luchesar Cekov

unread,
May 27, 2014, 11:10:46 AM5/27/14
to sbt...@googlegroups.com
Ok I figure it out by debugging the sbt jvm. I had a null value in the javaOptions in Test which was causing the NPE.

Now after I remove it I get a different error.

running ```java with options -classpath ...... sbt.ForkMain 53091 failed with exit code 1```

I am obliged to ask if you have any ideas?

Cheers,
Lucho


On Tuesday, May 27, 2014 1:12:56 PM UTC+1, Luchesar Cekov wrote:

Josh Suereth

unread,
May 27, 2014, 11:13:14 AM5/27/14
to sbt...@googlegroups.com

Not really.  If you can get the cli we call and try the command yourself, that may give better insight.

Unfortunately forking on the jvm is a dark art with lots of issues regarding grtting good error mesages.

--
You received this message because you are subscribed to the Google Groups "sbt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sbt-dev+u...@googlegroups.com.

Luchesar Cekov

unread,
May 27, 2014, 11:28:07 AM5/27/14
to sbt...@googlegroups.com
I am sure you sbt guys are properly proficient in the dark art of forking jvms :)

That't the first thing I did really. The result is java.net.ConnectException: Connection refused.

ForkMain is expecting a port as a first argument and it tries to open up a Socket to that port so there must be a server running on that port. I would've expected that server is the forked JVM with the running tests. The problem is there was no ServerSocket running on that port. Even if there was it had been closed when I gave it a go.

So it is either the forked JVM hasn't been started or there is some other problem connecting. Can I somehow force sbt to print the full output of the ForkMain jvm?

Do you know what is ForkMain trying to connect to? Is it the main JVM where sbt is running? 

Many thanks,
Lucho

Josh Suereth

unread,
May 27, 2014, 3:42:19 PM5/27/14
to sbt...@googlegroups.com
OOOOH, right.  ForkMain tries to immediately access the socket to the sbt instance and then sbt instance pushes the tests out the socket.

SOOO, if you're seeing socket closed on your end, it's because something is closing your socket (useful right?).   Without a stack trace or some other piece of info, we really can't do much to help.   Are you able to turn on debugging for sbt and trace through the test forking?


Bharat Kasodaria

unread,
Jun 27, 2014, 7:12:50 AM6/27/14
to sbt...@googlegroups.com
Getting the same error on test, Here is my stacktrace. any idea?

[error] Could not accept connection from test agent: class java.net.SocketExcept
ion: socket closed
java.net.SocketException: socket closed
        at java.net.DualStackPlainSocketImpl.accept0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketIm
pl.java:131)
        at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:
404)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
        at java.net.ServerSocket.implAccept(ServerSocket.java:545)
        at java.net.ServerSocket.accept(ServerSocket.java:513)
        at sbt.ForkTests$$anonfun$mainTestTask$1$Acceptor$2$.run(ForkTests.scala
:48)
        at java.lang.Thread.run(Thread.java:745)
[error] Error: Total 0, Failed 0, Errors 0, Passed 0

Thanks,
Bharat
Reply all
Reply to author
Forward
0 new messages