Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnable to start container - checkExposedPort - NullPointerException #513

Closed
VladoDemcak opened this issue Dec 6, 2017 · 3 comments · Fixed by #516
Closed

Unnable to start container - checkExposedPort - NullPointerException #513

VladoDemcak opened this issue Dec 6, 2017 · 3 comments · Fixed by #516
Assignees

Comments

@VladoDemcak
Copy link

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


@VladoDemcak VladoDemcak changed the title Unnable to start container - checkExposedPort Unnable to start container - checkExposedPort - NullPointerException Dec 6, 2017
@kiview
Copy link
Member

kiview commented Dec 7, 2017

Hi @VladoDemcak, can you please share a bit more of your code? Do you use @Rule or @ClassRule?

@rnorth
Copy link
Member

rnorth commented 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
Copy link
Author

@kiview

@ClassRule
    public static GenericContainer arangodbContainer = new FixedHostPortGenericContainer("arangodb:3.2.0")
            .withFixedExposedPort(arangoPort, 8529)
            .withEnv("ARANGO_NO_AUTH", "1")
            .waitingFor(
                    Wait.forHttp("/_db/_system/")
                        .forStatusCode(200));

@rnorth
we are using 1.4.2 version. 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:

inspectedContainer.getNetworkSettings().getPorts().getBindings().values().iterator().next()[0].getHostPortSpec();

rnorth added a commit that referenced this issue Dec 11, 2017
@rnorth rnorth self-assigned this Dec 11, 2017
rnorth added a commit that referenced this issue Dec 18, 2017
rnorth added a commit that referenced this issue Dec 18, 2017
… robustness (fixes #513).

Fix erroneous changelog entry for 1.5.0 release
rnorth added a commit that referenced this issue Dec 18, 2017
… robustness (fixes #513). (#516)

Fix erroneous changelog entry for 1.5.0 release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants