Gradle构建在进入:test 任务(junit tests)时失败。它给出了错误
Process 'Gradle Test Executor 1' finished with non-zero exit value 1
我在eclipse中使用gradle和java项目。 Gradle 1.12和Java 7.当在连接到数据库的类上运行测试时,似乎会出现问题。奇怪的是程序和测试作为java应用程序工作正常。数据库连接没有问题,它可以正确编译和运行。 gradle是否会做一些可能会弄乱它如何连接到外部数据库服务器?这个问题可能与数据库无关,因此任何解决方案都会受到赞赏。我看过网上和官方的gradle网站,但没有任何帮助。感谢。
修改
调试结果:
14:23:28.661 [DEBUG] [TestEventLogger]
14:23:28.661 [DEBUG] [TestEventLogger] Test Run PASSED
14:23:28.665 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':test'
14:23:28.665 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :test FAILED
14:23:28.665 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :test (Thread[main,5,main]) completed. Took 5.552 secs.
14:23:28.666 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 6.67 secs, idle: 0.021 secs
14:23:28.808 [LIFECYCLE] [org.gradle.BuildResultLogger]
14:23:28.808 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
14:23:28.808 [LIFECYCLE] [org.gradle.BuildResultLogger]
14:23:28.808 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 11.75 secs
14:23:28.811 [DEBUG] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopping 0 compiler daemon(s).
错误讯息:
Unexpected exception thrown.
org.gradle.messaging.remote.internal.MessageIOException: Could not read message from '/127.0.0.1:51041'.
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:88)
at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionReceive.run(MessageHub.java:230)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
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)
Caused by: com.esotericsoftware.kryo.KryoException: java.io.IOException: An existing connection was forcibly closed by the remote host
at com.esotericsoftware.kryo.io.Input.fill(Input.java:141)
at com.esotericsoftware.kryo.io.Input.require(Input.java:159)
at com.esotericsoftware.kryo.io.Input.readByte(Input.java:255)
at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:64)
at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:53)
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:83)
... 5 more
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at org.gradle.messaging.remote.internal.inet.SocketConnection$SocketInputStream.read(SocketConnection.java:167)
at com.esotericsoftware.kryo.io.Input.fill(Input.java:139)
... 10 more
Unexpected exception thrown.
org.gradle.messaging.remote.internal.MessageIOException: Could not write message [EndOfStream] to '/127.0.0.1:51041'.
at org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)
at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:279)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
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)
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:51)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
at org.gradle.messaging.remote.internal.inet.SocketConnection$SocketOutputStream.flush(SocketConnection.java:230)
at org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:113)
... 5 more
FAILED
答案 0 :(得分:9)
最有可能你的一个测试通过System.exit(1) 使用test -i
在控制台中显示测试结果可能会有所帮助答案 1 :(得分:1)
尝试使用./gradlew --stop
清理守护进程。这个对我有用。
这是我的错误。有时我在构建结束时得到一个IDLE,并且永无止境。
* What went wrong:
Execution failed for task ':test'.
> A problem occurred starting process 'Gradle Test Executor 1'
答案 2 :(得分:-1)
我遇到了类似的问题,但它是由 JAVA_TOOL_OPTIONS
引起的:
JAVA_TOOL_OPTIONS: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/dumps/
不存在的路径 /dumps/
导致了我的问题。