Skip to content

Unnable to start container - checkExposedPort - NullPointerException #513

Closed

Description

@VladoDemcak

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


Activity

  1. changed the title [-]Unnable to start container - checkExposedPort[/-] [+]Unnable to start container - checkExposedPort - NullPointerException[/+] on Dec 6, 2017
  2. kiview commented on Dec 7, 2017

    @kiview
    Member

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

  3. rnorth commented on Dec 7, 2017

    @rnorth
    Member

    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

  4. VladoDemcak commented on Dec 11, 2017

    @VladoDemcak
    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();
    
  5. added a commit that references this issue on Dec 11, 2017
    86aa381
  6. self-assigned this
    on Dec 11, 2017
  7. added 2 commits that reference this issue on Dec 18, 2017
    6539c36
    c9c2109
  8. added a commit that references this issue on Dec 18, 2017
    6d42f41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions