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

NoClassDefFoundError with a JAR created with custom shadow JAR task #897

Open
akshayamaldhure opened this issue Dec 4, 2023 · 0 comments

Comments

@akshayamaldhure
Copy link

akshayamaldhure commented Dec 4, 2023

Shadow Version

8.1.1

Gradle Version

------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------

Build time:   2023-08-17 07:06:47 UTC
Revision:     8afbf24b469158b714b36e84c6f4d4976c86fcd5

Kotlin:       1.9.0
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          11.0.17 (Amazon.com Inc. 11.0.17+8-LTS)
OS:           Mac OS X 14.1.2 aarch64

Expected Behavior

On creating and running a shadow JAR created with ./gradlew :myModule:shadowJarMyBotService, all the code paths should work.

Actual Behavior

The code paths containing the library references from the top level build.gradle and even from the current module itself fail with NoClassDefFoundError error.

Gradle Build Script(s)

// for the module JAR for running functional tests
shadowJar {
    zip64 true
    manifest.attributes["Main-Class"] = "entrypoint.Entrypoint"
    manifest.attributes["Launcher-Agent-Class"] = "org.aspectj.weaver.loadtime.Agent"
    from sourceSets.test.output
    from sourceSets.test.resources
    from sourceSets.main.output
    from sourceSets.main.resources
}

// needed for the Slackbot service
dependencies {
    shadow("com.slack.api:bolt-socket-mode:1.36.1")
    shadow("javax.websocket:javax.websocket-api:1.1")
    shadow("org.glassfish.tyrus.bundles:tyrus-standalone-client:1.19")
    shadow("org.slf4j:slf4j-simple:1.7.36")
}

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

// for running the Slackbot service
task shadowJarMyBotService (type: ShadowJar) {
    zip64 true
    archiveFileName = 'my-bot-service.jar'
    manifest.attributes["Main-Class"] = "slackBot.MyBotService"
    project.configurations.shadow.setTransitive(true);
    configurations = [project.configurations.shadow]
    from sourceSets.test.output
    from sourceSets.test.resources
    from sourceSets.main.output
    from sourceSets.main.resources
}
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

No branches or pull requests

1 participant