Skip to content

Package relocation doesn't relocate references in project source. Results in NoClassDefFound. #55

@kzarzycki

Description

@kzarzycki

Hi,
I'm having issue, with running your shadowJar plugin, more precisely when using "relocate" feature of it.
I'm trying to relocate all google libraries that I use( especially guava classes), to embed them in my jar and be independent of guava that is used in the platform I want to launch my jar in (it's Apache Storm, my jar is a Storm topology).

To achieve this I specify shadowJar task as following:

shadowJar {
     zip64 = true
    exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
    relocate 'com.google', 'mycompany.com.google'
}

I hope I'm right, that that should be it, i.e. all my classes in my jar, that used com.google.* classes, are now "rewritten" to use mycompany.com.google.* classes.
But I have a problem to run the shadow jar:

$ java -cp myjar-1.0-all.jar mycompany.MyMainClass
...
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/PrivateModule
...

When I unpacked the jar, I see that indeed all com.google classes landed in mycompany/com/google directory. There are empty directories in com/google, but I believe this is not the issue.
Do you know what is the issue? I'll be really grateful for your help as it is a major blocker to my project.

Environment:

  • Shadow version : 0.9.0-M5

  • JVM: 1.8.0_05 (Oracle Corporation 25.5-b02)

  • Gradle: 1.12-20140531062749+0000
    to have Shadow working with JVM 1.8, I had to asm to 5.x, I did this by overriding asm dependencies in buildscript:

    classpath 'org.ow2.asm:asm:5.0.3'
    classpath 'org.ow2.asm:asm-commons:5.0.3'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions