Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Maven jUnit error loading script class


    Kazpersky
     Share

    Recommended Posts

    So I've tried creating a script with maven and it seems to be having some issues with jUnit. Only in terminal though, the script runs.

    The project structure was auto generated with intelij, also added the jUnit dependancy just to be sure.

    Edit:

    Forgot to mention it only prints out that error message while refresing script manager. And it's the only script located there.

    Here is the error log: 

    23:56:33: [ERROR] Error loading script class: C:\Users\nosta\DreamBot\Scripts\original-script-name-uberjar.jar![org/codehaus/plexus/PlexusTestCase.class]:
    	java.lang.NoClassDefFoundError: junit/framework/TestCase
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(Unknown Source)
    	at java.security.SecureClassLoader.defineClass(Unknown Source)
    	at java.net.URLClassLoader.defineClass(Unknown Source)
    	at java.net.URLClassLoader.access$100(Unknown Source)
    	at java.net.URLClassLoader$1.run(Unknown Source)
    	at java.net.URLClassLoader$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at org.dreambot.1R.1(1R.java)
    	at org.dreambot.1R.3(1R.java)
    	at org.dreambot.1R.0a(1R.java)
    	at org.dreambot.1R.0b(1R.java)
    	at org.dreambot.1R.6(1R.java)
    	at org.dreambot.2v.lambda$refreshScripts$8(2v.java)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: junit.framework.TestCase
    	at java.net.URLClassLoader.findClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	... 18 more

     And here is how my pom.xml file:

    <?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>org.example</groupId>
        <artifactId>mavenScriptTemplate</artifactId>
        <version>1.0</version>
        <!-- dreambot cdn -->
        <repositories>
            <repository>
                <id>dreambot</id>
                <name>dreambot</name>
                <url>https://cdn.dreambot.org/maven/</url>
            </repository>
        </repositories>
    
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.2</version>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <groupId>org.dreambot</groupId>
                <artifactId>client</artifactId>
                <version>3.0.0</version>
            </dependency>
    
            <dependency>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
            </dependency>
        </dependencies>
    
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
    
            <!-- dreambot properties -->
            <dreambot.path>${user.home}/DreamBot/</dreambot.path>
        </properties>
    
        <!-- build jar file with dependencies -->
        <packaging>jar</packaging>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.2.4</version>
                    <configuration>
                        <finalName>script-name-uberjar</finalName>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <artifactSet>
                            <excludes>
                                <exclude>junit:junit</exclude>
                            </excludes>
                        </artifactSet>
                        <shadedClassifierName>dep-included</shadedClassifierName>
                        <outputDirectory>${dreambot.path}/Scripts</outputDirectory>
                        <transformers>
    <!--                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">-->
    <!--                            <mainClass>mavenScriptTemplate</mainClass>-->
    <!--                        </transformer>-->
                        </transformers>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>module-info.class</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>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit47</artifactId>
                            <version>3.0.0-M5</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    
    </project>

     

    Edited by Kazpersky
    Link to comment
    Share on other sites

    • 2 weeks later...

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.