我有一个junit测试,必须启动一个docker容器。 这是我使用的代码
@ClassRule
public static ContainerDslRule mysql = new ContainerDslRule(TestConfigConstants.DOCKER_IMAGE)
.withPortBinding(TestConfigConstants.PORT)
.withEnvironment("MYSQL_ROOT_PASSWORD", TestConfigConstants.PASSWORD,
"MYSQL_DATABASE", TestConfigConstants.DB,
"MYSQL_USER", TestConfigConstants.USERNAME,
"MYSQL_PASSWORD", TestConfigConstants.PASSWORD);
当我在安装了docker工具箱的Windows 7 pc上开始测试时,一切正常。但是,当我在Windows 10 PC上启动时,我有以下异常
java.lang.ExceptionInInitializerError
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(Unknown Source)
at sun.reflect.ReflectionFactory.newFieldAccessor(Unknown Source)
at java.lang.reflect.Field.acquireFieldAccessor(Unknown Source)
at java.lang.reflect.Field.getFieldAccessor(Unknown Source)
at java.lang.reflect.Field.get(Unknown Source)
at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.arquillian.spacelift.execution.ExecutionException: Execution of a task failed. Execution of a task failed. Unable to execute task SpawnProcessTask
at org.arquillian.spacelift.execution.ExecutionException.prependMessage(ExecutionException.java:70)
at org.arquillian.spacelift.execution.impl.FutureBasedExecution.unwrapException(FutureBasedExecution.java:173)
at org.arquillian.spacelift.execution.impl.FutureBasedExecution.await(FutureBasedExecution.java:101)
at org.arquillian.spacelift.task.os.ProcessBasedExecution.await(ProcessBasedExecution.java:149)
at org.arquillian.cube.docker.impl.util.CommandLineExecutor.execCommandAsArray(CommandLineExecutor.java:21)
at org.arquillian.cube.docker.impl.util.CommandLineExecutor.execCommand(CommandLineExecutor.java:13)
at org.arquillian.cube.docker.impl.util.AbstractCliInternetAddressResolver.getIp(AbstractCliInternetAddressResolver.java:29)
at org.arquillian.cube.docker.impl.util.AbstractCliInternetAddressResolver.ip(AbstractCliInternetAddressResolver.java:23)
at org.arquillian.cube.docker.impl.client.CubeDockerConfigurationResolver.resolveBoot2Docker(CubeDockerConfigurationResolver.java:317)
at org.arquillian.cube.docker.impl.client.CubeDockerConfigurationResolver.resolveServerIp(CubeDockerConfigurationResolver.java:209)
at org.arquillian.cube.docker.impl.client.CubeDockerConfigurationResolver.resolve(CubeDockerConfigurationResolver.java:66)
at org.arquillian.cube.docker.junit.rule.ContainerDslRule.initializeDockerClient(ContainerDslRule.java:74)
at org.arquillian.cube.docker.junit.rule.ContainerDslRule.<init>(ContainerDslRule.java:50)
at org.arquillian.cube.docker.junit.rule.ContainerDslRule.<init>(ContainerDslRule.java:44)
at it.advansys.gestionalebdf.server.controller.contact.customer.CustomerContactControllerTest.<clinit>(CustomerContactControllerTest.java:66)
... 19 more
Caused by: java.io.IOException: Cannot run program "boot2docker": CreateProcess error=2, Impossibile trovare il file specificato
at java.lang.ProcessBuilder.start(Unknown Source)
at org.arquillian.spacelift.task.os.SpawnProcessTask.process(SpawnProcessTask.java:107)
at org.arquillian.spacelift.task.os.SpawnProcessTask.process(SpawnProcessTask.java:34)
at org.arquillian.spacelift.task.Task.run(Task.java:98)
at org.arquillian.spacelift.task.Task$1.call(Task.java:70)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, Impossibile trovare il file specificato
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 9 more
有什么想法吗?
答案 0 :(得分:0)
我认为有与docker机器有关的东西,但现在还不确定问题,你在那台机器上安装了多少台机?如果它只有一个,你可以尝试手动启动它(即docker-machine start dev)
如果它有效,那么当docker-machine尚未启动时会出现错误。