3

I've added a Web Service using Axis2 to my project and now I can't run my application.

This is the classpath I am using:

<property name="classpath" location="bin:EventReservationCore/bin:EventReservationCore/db:EventReservationCore/lib/*:EventReservationCore/lib/util_iso2.jar:EventReservationCore/lib/sqlitejdbc-v056.jar:AuthorizationRMI/lib/AuthorizationService.jar:EventReservationCore/lib/activemq-all-5.4.3.jar:/home/ander/axis2-1.6.1/webapp/axis2.war"/>

And this is the target that runs until I add the Axis2 Web Service.

<target name="run.besocial">
            <java classname="eventReservationServer.ReservationEventServer" classpath="${classpath}" fork="true">
                <jvmarg value="-Djava.rmi.server.codebase=file:EventReservationCore/bin/ file:EventReservationCore/lib/util_iso2.jar"/>
                <jvmarg value="-Djava.security.policy=EventReservationCore/java.policy" />
            </java>
    </target>

As a result I get this error:

 [java] Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub
 [java]     at java.lang.ClassLoader.defineClass1(Native Method)
 [java]     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
 [java]     at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
 [java]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
 [java]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
 [java]     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
 [java]     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
 [java]     at java.security.AccessController.doPrivileged(Native Method)
 [java]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
 [java]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
 [java]     at eventReservationServer.eventServerGateway.WSEventServerGateway.getEvents(WSEventServerGateway.java:19)
 [java]     at eventReservationServer.ReservationEventServer.<init>(ReservationEventServer.java:101)
 [java]     at eventReservationServer.ReservationEventServer.main(ReservationEventServer.java:130)
 [java] Caused by: java.lang.ClassNotFoundException: org.apache.axis2.client.Stub
 [java]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 [java]     at java.security.AccessController.doPrivileged(Native Method)
 [java]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
 [java]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
 [java]     ... 15 more
user1314836
  • 219
  • 1
  • 4
  • 14

4 Answers4

5

If you are using tomcat, copy all the jar files located under axis2/lib folder to the tomcat/lib folder and also add them to the classpath like this D:\axis2-1.6.2\lib*

rookie_ron
  • 399
  • 5
  • 13
2

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub

Above error can be removed by adding axis2-kernel-1.6.2 to the class path, but you might start getting other errors after you have generated the stubs with wsdl2java.bat.

So you better add all the axis2-jars to classpath while compiling the client.

Hope this helps

rookie_ron
  • 399
  • 5
  • 13
0

None of the answers helped me. Here is then what I did.

I used eclipse to generate Runnable Jar(right click->Export->Runnable Jar) with all the libraries added as package. It gave me a JAR that I could run from command line.

Then I did diff between Jar from eclipse and Jar that my build created. I was able to find the missing dependencies that my build was not putting in Jar.

0

If you faced the same issue for JBoss class loader, follow the tips on here and here.

The most important part is to define a new module in JBoss module configurations, and also locate the module in you MANIFEST.MF file.

Maven will help you to do the later part. Following is a sample configuration to add axis module to your Manifest file.

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries> <!--Manually added JBoss Modules (that are not found by JBoss class loader) must be loaded here-->
                        <Dependencies>axis.axis</Dependencies>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

Depending to your packaging type, you would use other maven plugins like maven-jar-plugin or maven-war-plugin.

The dependency package name must match the name that you have specified to your module name in JBoss modules. The above axis module is defined in JBoss models as explained in the links above.

 <module xmlns="urn:jboss:module:1.1" name="axis.axis">
    <properties>
        <property name="jboss.api" value="private"/>
    </properties> 
 <!--  ...   -->
 </module>
Community
  • 1
  • 1
Youness
  • 1,920
  • 22
  • 28