Solved Bukkit classloader problem

Discussion in 'Spigot Plugin Development' started by Enfield, Mar 23, 2020.

  1. Ok this is a followup thread from my last thread: https://www.spigotmc.org/threads/java-12-i-cant-get-jaxb-to-work-in-my-maven-project.423669/

    trdr; I'm updating from Java8 to Java12-13 and since java 11 they removed a lib I use.
    So, I have an the lib I'm using called JAXB (Java API(Application Programing Interface) for XML(eXtensible Markup Language) Binding)
    However this lib isn't working in my fatjar when it is loaded by the server, but as a standalone executable JAR it works fine!

    If i drop the libs directly into the server JAR It also works, but in order for it to work I have to change "com.sun.xml.bind.v2.ContextFactory" to "com.sun.xml.internal.bind.v2.ContextFactory" However when being ran as a executable jar it doesn't need the internal bit to work, looks for "com.sun.xml.bind.v2.ContextFactory" instead.

    This seems like a classloader issue / incompatibility with the lib vs the servers way of loading plugins, is there a fix for this?

    the lib(s) are:

    Code (Text):
            <dependency>
                <groupId>jakarta.xml.bind</groupId>
                <artifactId>jakarta.xml.bind-api</artifactId>
                <version>2.3.2</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>2.3.2</version>
            </dependency>
    Perhaps a Different lib exists of the same functionality?
     
  2. Code (Text):
    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>

    jaxb-impl could solve it.
     
  3. Code (Text):
    [23:47:03 WARN]: javax.xml.bind.DataBindingException: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
    [23:47:03 WARN]:  - with linked exception:
    [23:47:03 WARN]: [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    [23:47:03 WARN]:        at javax.xml.bind.JAXB._marshal(JAXB.java:559)
    [23:47:03 WARN]:        at javax.xml.bind.JAXB.marshal(JAXB.java:317)
    [23:47:03 WARN]:        at me.enfield.server.<server>.minesuiteus.Minesuiteus.marshalFile(Minesuiteus.java:698)
    [23:47:03 WARN]:        at me.enfield.server.<server>.minesuiteus.Minesuiteus.testXml(Minesuiteus.java:191)
    [23:47:03 WARN]:        at me.enfield.server.<server>.minesuiteus.Minesuiteus.onEnable(Minesuiteus.java:144)
    [23:47:03 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263)
    [23:47:03 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    [23:47:03 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:435)
    [23:47:03 WARN]:        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:470)
    [23:47:03 WARN]:        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:384)
    [23:47:03 WARN]:        at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:482)
    [23:47:03 WARN]:        at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:299)
    [23:47:03 WARN]:        at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:885)
    [23:47:03 WARN]:        at java.base/java.lang.Thread.run(Thread.java:830)
    [23:47:03 WARN]: Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
    Same error sadly, It does run as a standalone app (as it did before) But won't run when loaded as a plugin.
     
    #4 Enfield, Mar 25, 2020
    Last edited: Mar 25, 2020
  4. Do you have a sample project that we can use for testing/finding a solution? I'm not setting one up myself.