Jump to content

[1.15.2 - Recommended] Dependency not loading when using 'embed'


jskidd3

Recommended Posts

Hello,

 

I've carefully followed the ForgeGradle dependency documentation as I need to embed a few dependencies in my project.

 

Most of these dependencies are loading and can be used as expected, but one is throwing java.lang.NoClassDefFoundError when I try to make use of the library.

 

I can see that the library has been embedded in the jar file, but the mod crashes when I try to access the library.

 

I'd really appreciate any help working around this.

 

Here is my build.gradle:

 

Spoiler

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0.0'
group = 'io.jupiter.link' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'link'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

minecraft {
    mappings channel: 'snapshot', version: '20190719-1.14.3'
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
    
    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

    // Default run configurations.
    // These can be tweaked, removed, or duplicated as needed.
    runs {
        client {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }
    }
}

repositories {
    mavenCentral()
}

configurations {
    embed
    compile.extendsFrom(embed)
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.15.2-31.1.0'

    embed 'io.socket:engine.io-server:1.3.1'
    embed group: 'com.corundumstudio.socketio', name: 'netty-socketio', version: '1.7.17'
    embed group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5'
    embed group: 'org.jmdns', name: 'jmdns', version: '3.5.5'
    embed 'org.slf4j:slf4j-nop:1.7.25'
}

jar {
    manifest {
        attributes([
            "Specification-Title": "Link",
            "Specification-Vendor": "Jupiter",
            "Specification-Version": "1", // We are version 1 of ourselves
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"Jupiter",
            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
    
    from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }
}

def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
    type 'jar'
    builtBy 'reobfJar'
}
publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact reobfArtifact
        }
    }
    repositories {
        maven {
            url "file:///${project.projectDir}/mcmodsrepo"
        }
    }
}

 

Here is the fairly typical crash log:

 

Spoiler

[26Apr2020 13:31:07.993] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, eggy, --version, 1.15.2-forge-31.1.47, --gameDir, /Users/jupiter/Library/Application Support/minecraft, --assetsDir, /Users/jupiter/Library/Application Support/minecraft/assets, --assetIndex, 1.15, --uuid, 9016adc5a3cb4677a6ae5b67653c08d0, --accessToken, ❄❄❄❄❄❄❄❄, --userType, mojang, --versionType, release, --launchTarget, fmlclient, --fml.forgeVersion, 31.1.47, --fml.mcVersion, 1.15.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20200414.225201]
[26Apr2020 13:31:07.996] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 5.0.0-milestone.4+67+b1a340b starting: java version 1.8.0_74 by Oracle Corporation
[26Apr2020 13:31:08.123] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust
[26Apr2020 13:31:08.882] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlclient' with arguments [--version, 1.15.2-forge-31.1.47, --gameDir, /Users/jupiter/Library/Application Support/minecraft, --assetsDir, /Users/jupiter/Library/Application Support/minecraft/assets, --uuid, 9016adc5a3cb4677a6ae5b67653c08d0, --username, eggy, --assetIndex, 1.15, --accessToken, ❄❄❄❄❄❄❄❄, --userType, mojang, --versionType, release]
[26Apr2020 13:31:10.792] [Render thread/INFO] [net.minecraft.client.Minecraft/]: Setting user: eggy
[26Apr2020 13:31:17.454] [Render thread/INFO] [net.minecraft.client.Minecraft/]: Backend library: LWJGL version 3.2.1 build 12
[26Apr2020 13:31:19.409] [modloading-worker-9/INFO] [net.minecraftforge.common.ForgeMod/FORGEMOD]: Forge mod loading, version 31.1.47, for MC 1.15.2 with MCP 20200414.225201
[26Apr2020 13:31:19.409] [modloading-worker-9/INFO] [net.minecraftforge.common.MinecraftForge/FORGE]: MinecraftForge v31.1.47 Initialized
[26Apr2020 13:31:19.728] [Render thread/INFO] [io.jupiter.link.ExampleMod/]: HELLO from Register Block
[26Apr2020 13:31:22.151] [Render thread/INFO] [net.minecraft.resources.SimpleReloadableResourceManager/]: Reloading ResourceManager: Default, Mod Resources
[26Apr2020 13:31:23.006] [modloading-worker-11/INFO] [io.jupiter.link.ExampleMod/]: HELLO FROM PREINIT
[26Apr2020 13:31:23.007] [modloading-worker-11/INFO] [io.jupiter.link.ExampleMod/]: DIRT BLOCK >> minecraft:dirt
[26Apr2020 13:31:23.129] [Forge Version Check/INFO] [net.minecraftforge.fml.VersionChecker/]: [forge] Starting version check at https://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[26Apr2020 13:31:23.758] [Forge Version Check/INFO] [net.minecraftforge.fml.VersionChecker/]: [forge] Found status: OUTDATED Current: 31.1.47 Target: 31.1.50
[26Apr2020 13:31:24.052] [modloading-worker-11/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: javax/jmdns/JmDNS
  Index: 1
  Listeners:
    0: NORMAL
    1: net.minecraftforge.eventbus.EventBus$$Lambda$2093/839624607@100a2528
java.lang.NoClassDefFoundError: javax/jmdns/JmDNS
  at io.jupiter.link.ExampleServiceRegistration.start(ExampleServiceRegistration.java:15)
  at io.jupiter.link.ExampleMod.setup(ExampleMod.java:82)
  at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212)
  at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204)
  at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
  at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106)
  at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
  at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
  at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112)
  at net.minecraftforge.fml.ModList.lambda$null$10(ModList.java:134)
  at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
  at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
  at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
  at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
  at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.ClassNotFoundException: javax.jmdns.JmDNS
  at java.lang.ClassLoader.findClass(ClassLoader.java:530)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:92)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 19 more

[26Apr2020 13:31:24.054] [modloading-worker-11/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Caught exception during event FMLCommonSetupEvent dispatch for modid magma
java.lang.NoClassDefFoundError: javax/jmdns/JmDNS
  at io.jupiter.link.ExampleServiceRegistration.start(ExampleServiceRegistration.java:15) ~[?:1.0.0]
  at io.jupiter.link.ExampleMod.setup(ExampleMod.java:82) ~[?:1.0.0]
  at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212) ~[eventbus-2.0.0-milestone.1-service.jar:?]
  at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204) ~[eventbus-2.0.0-milestone.1-service.jar:?]
  at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-2.0.0-milestone.1-service.jar:?]
  at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106) ~[?:31.1]
  at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_74]
  at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_74]
  at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112) ~[?:?]
  at net.minecraftforge.fml.ModList.lambda$null$10(ModList.java:134) ~[?:?]
  at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) [?:1.8.0_74]
  at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) [?:1.8.0_74]
  at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) [?:1.8.0_74]
  at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291) [?:1.8.0_74]
  at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_74]
Caused by: java.lang.ClassNotFoundException: javax.jmdns.JmDNS
  at java.lang.ClassLoader.findClass(ClassLoader.java:530) ~[?:1.8.0_74]
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_74]
  at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:92) ~[modlauncher-5.0.0-milestone.4.jar:?]
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_74]
  ... 19 more
[26Apr2020 13:31:24.056] [Server-Worker-1/FATAL] [net.minecraftforge.fml.ModLoader/LOADING]: Failed to complete lifecycle event SETUP, 1 errors found
[26Apr2020 13:31:24.056] [Server-Worker-1/FATAL] [net.minecraftforge.eventbus.EventBus/EVENTBUS]: EventBus 0 shutting down - future events will not be posted.
java.lang.Exception: stacktrace
  at net.minecraftforge.eventbus.EventBus.shutdown(EventBus.java:278) ~[eventbus-2.0.0-milestone.1-service.jar:?]
  at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:115) ~[?:?]
  at net.minecraftforge.fml.client.ClientModLoader.startModLoading(ClientModLoader.java:123) ~[?:?]
  at net.minecraftforge.fml.client.ClientModLoader.lambda$onreload$3(ClientModLoader.java:105) ~[?:?]
  at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:113) ~[?:?]
  at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626) [?:1.8.0_74]
  at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_74]
[26Apr2020 13:31:24.876] [Server-Worker-3/ERROR] [net.minecraftforge.fml.ModLoader/LOADING]: Skipping lifecycle event ENQUEUE_IMC, 1 errors found.
[26Apr2020 13:31:24.877] [Server-Worker-3/FATAL] [net.minecraftforge.fml.ModLoader/LOADING]: Failed to complete lifecycle event ENQUEUE_IMC, 1 errors found
[26Apr2020 13:31:24.877] [Server-Worker-3/FATAL] [net.minecraftforge.eventbus.EventBus/EVENTBUS]: EventBus 0 shutting down - future events will not be posted.
java.lang.Exception: stacktrace
  at net.minecraftforge.eventbus.EventBus.shutdown(EventBus.java:278) ~[eventbus-2.0.0-milestone.1-service.jar:?]
  at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:115) ~[?:?]
  at net.minecraftforge.fml.client.ClientModLoader.finishModLoading(ClientModLoader.java:137) ~[?:?]
  at net.minecraftforge.fml.client.ClientModLoader.lambda$onreload$4(ClientModLoader.java:107) ~[?:?]
  at java.util.concurrent.CompletableFuture.uniRun(CompletableFuture.java:705) [?:1.8.0_74]
  at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:687) [?:1.8.0_74]
  at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_74]
  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_74]
[26Apr2020 13:31:25.105] [Render thread/INFO] [net.minecraft.client.audio.SoundSystem/]: OpenAL initialized.
[26Apr2020 13:31:25.110] [Render thread/INFO] [net.minecraft.client.audio.SoundEngine/SOUNDS]: Sound engine started
[26Apr2020 13:31:25.321] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 1024x512x4 minecraft:textures/atlas/blocks.png-atlas
[26Apr2020 13:31:25.335] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 128x128x4 minecraft:textures/atlas/signs.png-atlas
[26Apr2020 13:31:25.336] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x512x4 minecraft:textures/atlas/banner_patterns.png-atlas
[26Apr2020 13:31:25.337] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x512x4 minecraft:textures/atlas/shield_patterns.png-atlas
[26Apr2020 13:31:25.338] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x256x4 minecraft:textures/atlas/chest.png-atlas
[26Apr2020 13:31:25.339] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x256x4 minecraft:textures/atlas/beds.png-atlas
[26Apr2020 13:31:25.340] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x256x4 minecraft:textures/atlas/shulker_boxes.png-atlas
[26Apr2020 13:31:25.772] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x256x0 minecraft:textures/atlas/particles.png-atlas
[26Apr2020 13:31:25.773] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x256x0 minecraft:textures/atlas/paintings.png-atlas
[26Apr2020 13:31:25.773] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 128x128x0 minecraft:textures/atlas/mob_effects.png-atlas

 

Edited by jskidd3
Additional clarification
Link to comment
Share on other sites

This post (and your reply specifically) seems very relevant as fmDNS uses org.apache libs.

 

The hack isn't working with 1.15.2 but I'm keen to figure out a way of doing this using transformation anyway.

 

 

 

Edited by jskidd3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.