29.9.10

Starts the Test Agent of SNMP4J-Agent Project

If you want to start the test agent of SNMP4J-Agent simply by entering the following command:

$mvn exec:java –Dexec.mainClass=org.snmp4j.agent.test.TestAgent

You will get the following Error:

java.lang.NoClassDefFoundError: org/snmp4j/event/CounterListener
Caused by: java.lang.ClassNotFoundException: org.snmp4j.event.CounterListener
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: org.snmp4j.agent.test.TestAgent.  Program will exit.
Exception in thread "main"

 

To solve the problem, please modify the pom.xml file and remove the scope of two dependencies:

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
                        <!--
            <scope>provided</scope>
                        -->
        </dependency>
        <dependency>
            <groupId>org.snmp4j</groupId>
            <artifactId>snmp4j</artifactId>
            <version>1.11.1</version>
                        <!--
            <scope>provided</scope>
                        -->
        </dependency>

No comments: