0

Am getting below exception when trying to run integration test which has TestCOntainers GenerciContainer for redis

public GenericContainer redis = new GenericContainer<>("redis:3.0.6")
            .withExposedPorts(6379);

Exception

java.lang.NoClassDefFoundError: com/sun/jna/Platform
    at org.rnorth.ansi.CapabilityDetection.isTty(CapabilityDetection.java:38)
    at org.rnorth.ansi.AnsiLite.isEnabled(AnsiLite.java:169)
    at org.rnorth.ansi.AnsiLite.toString(AnsiLite.java:134)
    at java.lang.String.valueOf(String.java:2994)
    at java.lang.StringBuilder.append(StringBuilder.java:131)
    at org.rnorth.visibleassertions.VisibleAssertions.info(VisibleAssertions.java:59)
    at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:129)
    at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:142)
    at com.target.sparkbulkapp.IntegrationTest.$spock_initializeFields(IntegrationTest.groovy:51)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Platform
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 9 more

in general if we add testcontainers depdency it will bring jna depdency also , but in my case it is not below the image

enter image description here

If you see here only jna-platform is bring in not jna , and my issue of class not found excpetion for Platform is because of this only , i asked my team member to add this testcontainers , then i saw jna is being added in this case , what might be reason why it is not added in my case

Bravo
  • 8,589
  • 14
  • 48
  • 85
  • can we get your Java version and version of TestContainers please. Is your test using JUint? – Benjamin Slabbert Dec 12 '19 at 14:11
  • integration test in written in spock , build tool is gradle , java version 8 – Bravo Dec 13 '19 at 05:22
  • am trying to add compile group: 'net.java.dev.jna', name: 'jna', version: '5.5.0' , to my build.gradle , but this is not present on my project classpath , why it is not present ? am i missing any thing ? – Bravo Dec 13 '19 at 09:16

0 Answers0