Jump to content

Recommended Posts

Posted

My mod requires four dependencies, so I read the documentation for gradle and pulled a few lines from stackoverflow. Here is the relevant excerpt from my build file:

 

configurations{
    customCompile
}
dependencies {
    // http://mvnrepository.com/artifact/com.jcraft/jsch
    customCompile 'com.jcraft:jsch:0.1.53'


    // http://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit
    customCompile 'org.eclipse.jgit:org.eclipse.jgit:4.3.1.201605051710-r'


    // http://mvnrepository.com/artifact/org.slf4j/slf4j-api
    customCompile 'org.slf4j:slf4j-api:1.7.21'

    // http://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12
    customCompile 'org.slf4j:slf4j-log4j12:1.7.21'

    // http://mvnrepository.com/artifact/log4j/log4j
    customCompile group: 'log4j', name: 'log4j', version: '1.2.17'
    compile configurations.customCompile


}
jar{
    from ( configurations.customCompile.collect { it.isDirectory() ? it : zipTree(it)}) { exclude 'META-INF/**' }
    manifest {
        attributes 'Main-Class': 'Test'
    }
}

 

My mod compiles with all of the classes for my dependencies bundled inside the jar, but when I actually use code that invokes the slf4j logger via jgit (from a server command while the game is running), I get the following error:

 

Exception in thread "Thread-13" [23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at org.eclipse.jgit.util.FS.<clinit>(FS.java:160)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at org.eclipse.jgit.api.Git.open(Git.java:99)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at shoeboxam.gitstream.GitManager.pull(GitManager.java:123)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at shoeboxam.gitstream.commands.CommandUpdateThread.remote_get(CommandUpdateThread.java:157)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at shoeboxam.gitstream.commands.CommandUpdateThread.run(CommandUpdateThread.java:31)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:101)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[23:38:03] [Thread-13/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1061]: 	... 5 more

 

The referenced file, org/slf4j/LoggerFactory.class, exists in my mod jar. Is slf4j failing to be included in the classpath? That's why I packed the jar. Please note, if I don't bundle the files via the customCompile, the Minecraft server errors on startup.

 

Any help is appreciated.

  • 3 years later...

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.

Announcements



×
×
  • Create New...

Important Information

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