Repository navigation
Unnable to start container - checkExposedPort - NullPointerException #513
Copy link
Copy link
Closed
Description
Hi,
this is not very common issue (sometime happens, but not very often). Testcontainers java client is failing due NullPointerException while container initialization in checkExposedPort method. See error below:
java.lang.ExceptionInInitializerError
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.get(Field.java:393)
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.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.NullPointerException
at org.testcontainers.DockerClientFactory.checkExposedPort(DockerClientFactory.java:186)
at org.testcontainers.DockerClientFactory.lambda$client$1(DockerClientFactory.java:129)
at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:230)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:118)
at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:116)
at org.testcontainers.containers.FixedHostPortGenericContainer.<init>(FixedHostPortGenericContainer.java:16)
at Test.<clinit>(Test.java:62)
... 26 more
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Unnable to start container - checkExposedPort[/-][+]Unnable to start container - checkExposedPort - NullPointerException[/+]kiview commentedon Dec 7, 2017
Hi @VladoDemcak, can you please share a bit more of your code? Do you use
@Ruleor@ClassRule?rnorth commentedon Dec 7, 2017
I think this might be happening during the 'pre-flight checks' (where it's checking if the Docker environment looks healthy, after the disk space and mountable file checks). Can you confirm that @VladoDemcak ?
Also it'd be useful to know which version of Testcontainers we're using so that we can line up the line numbers in the stack trace!
Thanks
VladoDemcak commentedon Dec 11, 2017
@kiview
@rnorth
we are using
1.4.2version. Probably it's happening in the checks of environment but I am not sure. Anyway I think there should be some check for NullPointer. I was not able to spot what was NullPointer (as I said it's happening unpredictable). But I guess it's this line:Add retry logic around checkExposedPort pre-flight check for improved…
Add retry logic around checkExposedPort pre-flight check for improved…
Add retry logic around checkExposedPort pre-flight check for improved…
Add retry logic around checkExposedPort pre-flight check for improved…