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

java.lang.NoClassDefFoundError after upgrading mysql to 1.11.1 #1342

Closed
rrhartjr opened this issue Mar 26, 2019 · 8 comments
Closed

java.lang.NoClassDefFoundError after upgrading mysql to 1.11.1 #1342

rrhartjr opened this issue Mar 26, 2019 · 8 comments
Assignees
Milestone

Comments

@rrhartjr
Copy link

I am creating a MySQLContainer with an init script

public static MySQLContainer mysql = (MySQLContainer) new MySQLContainer().withInitScript("sql/create_schema.sql");

This results in the following exception

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	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)
	... 24 more

This instantiation worked fine on 1.10.7

I checked with Slack and they suggested I report this as the shading changing in 1.11

@bsideup bsideup self-assigned this Mar 26, 2019
@bsideup bsideup added this to the next milestone Mar 26, 2019
@bsideup bsideup pinned this issue Mar 26, 2019
@bsideup
Copy link
Member

bsideup commented Mar 26, 2019

Thanks for reporting!

Meanwhile, you should be able to workaround it by adding 'org.apache.commons:commons-lang3:3.8.1' dependency.

@robfrank
Copy link
Contributor

robfrank commented Mar 28, 2019

commons lang 3.8.1 doesn't works, commons lang 2.6 is right

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
</dependency>
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'

@bsideup
Copy link
Member

bsideup commented Mar 28, 2019

@robfrank you're right, my bad! 👍

@codefromthecrypt
Copy link

to sort this completely, I needed to add commons-io as well

    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.6</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.5</version>
      <scope>test</scope>
    </dependency>

@bsideup
Copy link
Member

bsideup commented Apr 11, 2019

We were able to find the cause and fix it in #1390.
We will try to verify it ourselves, but would appreciate if somebody here can try it with their projects to verify that now it works correctly, with Jitpack or by installing locally.

@rrhartjr
Copy link
Author

Switched to:

        <dependency>
            <groupId>com.github.testcontainers</groupId>
            <artifactId>testcontainers-java</artifactId>
            <version>-SNAPSHOT</version>
        </dependency>

image

No more class loader error!

@bsideup
Copy link
Member

bsideup commented Apr 11, 2019

Umm...I don't think that's the right dependency (1.2.1 makes me think so).
Could you please try:

com.github.testcontainers.testcontainers-java:testcontainers:master-SNAPSHOT

and:

com.github.testcontainers.testcontainers-java:mysql:master-SNAPSHOT

@rrhartjr
Copy link
Author

Ok second try using master-SNAPSHOT.. still no class loader error!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants