简体   繁体   中英

Deeplearning4j class not found

first of all thank you for taking the time to help me. My name is Matt and I've been trying to learn java, as well as creating mc plugins. I've been trying to make a spigot plugin(for MC) that has deep learning in it. I am trying to use deeplearning4j. I know I could put this question on the spigotmc website but I don't think they would be very helpful, as from looking at previous posts on spigotmc it doesn't look like many of them have a lot of knowledge on dl4j. So what I have done so far is use the quickstart guide on dl4j's website to setup maven and Intellij and create a maven project within intellij and add the dependencies for deeplearning4j, here is my POM.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0         http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.gmail.mateo.lack</groupId>
<artifactId>SNAC5</artifactId>
<version>1.0-SNAPSHOT</version>

<repositories>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
</repositories>
<properties>

    <dl4j.version>1.0.0-beta3</dl4j.version>

    <nd4j.version>1.0.0-beta3</nd4j.version>

    <logback.version>1.2.3</logback.version>

    <java.version>1.8</java.version>

    <maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>

</properties>
<dependencies>
    <!--Spigot API-->
    <dependency>
        <groupId>com.gmail.mateo.lack</groupId>
        <artifactId>spigot</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>C:/Users/mlavatar/Downloads/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>nd4j-native-platform</artifactId>
        <version>1.0.0-beta3</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>1.0.0-beta3</version>
    </dependency>
    <dependency>
        <groupId>org.datavec</groupId>
        <artifactId>datavec-hadoop</artifactId>
        <version>1.0.0-beta3</version>
    </dependency>
    <dependency>
        <groupId>org.datavec</groupId>
        <artifactId>datavec-api</artifactId>
        <version>1.0.0-beta3</version>
    </dependency>
    <dependency>
        <groupId>com.gmail.mateo.lack</groupId>
        <artifactId>ShatteredStaff</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>C:/Users/mlavatar/Desktop/MyPlugins/ShatteredStaff.jar</systemPath>
    </dependency>
</dependencies>
<build>

    <plugins>

        <!-- Maven compiler plugin: compile for Java 8 -->

        <plugin>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-compiler-plugin</artifactId>

            <version>3.5.1</version>

            <configuration>

                <source>1.8</source>

                <target>1.8</target>

            </configuration>

        </plugin>





        <!--

        Maven shade plugin configuration: this is required so that if you build a single JAR file (an "uber-jar")

        it will contain all the required native libraries, and the backends will work correctly.

        Used for example when running the following commants



        mvn package

        cd target

        java -cp deeplearning4j-examples-1.0.0-beta-bin.jar org.deeplearning4j.LenetMnistExample

        -->

        <plugin>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-shade-plugin</artifactId>

            <version>2.4.3</version>

            <configuration>

                <shadedArtifactAttached>true</shadedArtifactAttached>

                <shadedClassifierName>bin</shadedClassifierName>

                <createDependencyReducedPom>true</createDependencyReducedPom>

                <filters>

                    <filter>

                        <artifact>*:*</artifact>

                        <excludes>

                            <exclude>org/datanucleus/**</exclude>

                            <exclude>META-INF/*.SF</exclude>

                            <exclude>META-INF/*.DSA</exclude>

                            <exclude>META-INF/*.RSA</exclude>

                        </excludes>

                    </filter>

                </filters>

            </configuration>



            <executions>

                <execution>

                    <phase>package</phase>

                    <goals>

                        <goal>shade</goal>

                    </goals>

                    <configuration>

                        <transformers>

                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">

                                <resource>reference.conf</resource>

                            </transformer>

                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

                            </transformer>

                        </transformers>

                    </configuration>

                </execution>

            </executions>

        </plugin>

    </plugins>

</build>
</project>

However, the problem is, once I export it (by going to right, maven, lifecycle, package) and I try out the jar in the plugins folder I get this error:

09.12 13:58:02 [Server] ERROR Could not load 'plugins/SAC.jar' in folder 'plugins'
09.12 13:58:02 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: org/nd4j/linalg/schedule/ISchedule
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:331) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:254) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:293) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:202) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
09.12 13:58:02 [Server] INFO Caused by: java.lang.NoClassDefFoundError: org/nd4j/linalg/schedule/ISchedule
09.12 13:58:02 [Server] INFO at SAC.sac.<init>(sac.java:48) ~[?:?]
09.12 13:58:02 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO ... 6 more
09.12 13:58:02 [Server] INFO Caused by: java.lang.ClassNotFoundException: org.nd4j.linalg.schedule.ISchedule
09.12 13:58:02 [Server] INFO at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:102) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:87) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at SAC.sac.<init>(sac.java:48) ~[?:?]
09.12 13:58:02 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_191]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 13:58:02 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]

I have tried to google this error and nothing useful has come up, I've searched this site for answers, and most of them point me back to the quickstart guide which I followed in the first place. Help would be very much appreciated.

EDIT: After using an Uberjar I get this error:

ERROR Could not load 'plugins/SAC.jar' in folder 'plugins'
09.12 18:17:31 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:331) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:254) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:293) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:202) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
09.12 18:17:31 [Server] INFO Caused by: java.lang.ExceptionInInitializerError
09.12 18:17:31 [Server] INFO at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:683) ~[?:?]
09.12 18:17:31 [Server] INFO at KillAura.kMain.<init>(kMain.java:118) ~[?:?]
09.12 18:17:31 [Server] INFO at SAC.sac.<init>(sac.java:48) ~[?:?]
09.12 18:17:31 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO ... 6 more
09.12 18:17:31 [Server] INFO Caused by: java.lang.RuntimeException: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
09.12 18:17:31 [Server] INFO at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5484) ~[?:?]
09.12 18:17:31 [Server] INFO at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:215) ~[?:?]
09.12 18:17:31 [Server] INFO at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:683) ~[?:?]
09.12 18:17:31 [Server] INFO at KillAura.kMain.<init>(kMain.java:118) ~[?:?]
09.12 18:17:31 [Server] INFO at SAC.sac.<init>(sac.java:48) ~[?:?]
09.12 18:17:31 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO ... 6 more
09.12 18:17:31 [Server] INFO Caused by: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
09.12 18:17:31 [Server] INFO at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:213) ~[?:?]
09.12 18:17:31 [Server] INFO at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5481) ~[?:?]
09.12 18:17:31 [Server] INFO at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:215) ~[?:?]
09.12 18:17:31 [Server] INFO at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:683) ~[?:?]
09.12 18:17:31 [Server] INFO at KillAura.kMain.<init>(kMain.java:118) ~[?:?]
09.12 18:17:31 [Server] INFO at SAC.sac.<init>(sac.java:48) ~[?:?]
09.12 18:17:31 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_191]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d"]
09.12 18:17:31 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper-1.8.8.jar:git-PaperSpigot-"4c7641d

EDIT: Log after building

x86_64:3.4.3-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica-platform:jar:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:android-arm:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:android-arm64:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:android-x86:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:android-x86_64:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:linux-x86:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:linux-x86_64:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:linux-armhf:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:linux-ppc64le:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:macosx-x86_64:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:windows-x86:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.bytedeco.javacpp-presets:leptonica:jar:windows-x86_64:1.76.0-1.4.3 in the shaded jar. [INFO] Including org.deeplearning4j:deeplearning4j-ui-components:jar:1.0.0-beta3 in the shaded jar. [INFO] Including org.datavec:datavec-hadoop:jar:1.0.0-beta3 in the shaded jar. [INFO] Including com.sun.xml.bind:jaxb-core:jar:2.2.11 in the shaded jar. [INFO] Including com.sun.xml.bind:jaxb-impl:jar:2.2.11 in the shaded jar. [INFO] Including io.netty:netty:jar:3.10.4.Final in the shaded jar. [INFO] Including org.apache.zookeeper:zookeeper:jar:3.4.6 in the shaded jar. [INFO] Including jline:jline:jar:0.9.94 in the shaded jar. [INFO] Including junit:junit:jar:3.8.1 in the shaded jar. [INFO] Including org.datavec:datavec-api:jar:1.0.0-beta3 in the shaded jar. [INFO] Including org.jetbrains:annotations:jar:13.0 in the shaded jar. [INFO] Including commons-codec:commons-codec:jar:1.10 in the shaded jar. [INFO] Including joda-time:joda-time:jar:2.2 in the shaded jar. [INFO] Including org.yaml:snakeyaml:jar:1.12 in the shaded jar. [INFO] Including org.freemarker:freemarker:jar:2.3.23 in the shaded jar. [INFO] Including org.nd4j:nd4j-common:jar:1.0.0-beta3 in the shaded jar. [INFO] Including com.clearspring.analytics:stream:jar:2.7.0 in the shaded jar. [INFO] Including net.sf.opencsv:opencsv:jar:2.3 in the shaded jar. [INFO] Including com.tdunning:t-digest:jar:3.2 in the shaded jar. [INFO] Including it.unimi.dsi:fastutil:jar:6.5.7 in the shaded jar. [INFO] Including ch.qos.logback:logback-classic:jar:1.2.3 in the shaded jar. [INFO] Including ch.qos.logback:logback-core:jar:1.2.3 in the shaded jar. [WARNING] nd4j-base64-1.0.0-beta3.jar, nd4j-api-1.0.0-beta3.jar define 1 overlapping classes: [WARNING] - org.nd4j.serde.base64.Nd4jBase64 [WARNING] maven-shade-plugin has detected that some class files are [WARNING] present in two or more JARs. When this happens, only one [WARNING] single version of the class is copied to the uber jar. [WARNING] Usually this is not harmful and you can skip these warnings, [WARNING] otherwise try to manually exclude artifacts based on [WARNING] mvn dependency:tree -Ddetail=true and the above output. [WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/ [INFO] Attaching shaded artifact. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:44 min [INFO] Finished at: 2018-12-10T21:13:33-05:00 [INFO] Final Memory: 43M/447M [INFO] ------------------------------------------------------------------------

Theres a little more at the beginning but I can't fit it in here.

Create an uberjar and use that for your plugin. Use the maven shade plugin to do this: https://github.com/deeplearning4j/dl4j-examples/blob/master/standalone-sample-project/pom.xml#L91

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM