Using Axis2/Java to generate code from WSDL

7,031

Solution 1

Based on Riccardo Murri's answer, I was able to determine all the jar files required for the classpath:

java -cp /usr/share/java/axis.jar:/usr/share/java/commons-logging.jar:/usr/share/java/commons-logging-api.jar:/usr/share/java/commons-logging-adapters.jar:/usr/share/java/commons-discovery.jar:/usr/share/java/jaxrpc.jar:/usr/share/java/wsdl4j.jar org.apache.axis.wsdl.WSDL2Java foo.wsdl

Solution 2

You seem to be lacking the commons-logging jar in your classpath:

  1. Install Ubuntu package libcommons-logging-java:

    sudo apt-get install libcommons-logging-java

  2. Append /usr/share/java/commons-logging.jar and its relatives to your classpath:

    java -cp /usr/share/java/axis.jar:/usr/share/java/commons-logging.jar:/usr/share/java/commons-logging-api.jar:/usr/share/java/commons-logging-adapters.jar org.apache.axis.wsdl.WSDL2Java foo.wsdl

It's quite likely that there will be other dependencies missing; you might want to use the JarAnalyizer tool to find them and add to the classpath.

Share:
7,031

Related videos on Youtube

Lorin Hochstein
Author by

Lorin Hochstein

Software engineer, often doing operations stuff. Once upon a time I was an academic. I work on the Delivery Engineering team at Netflix.

Updated on September 17, 2022

Comments

  • Lorin Hochstein
    Lorin Hochstein over 1 year

    I'm trying to use Axis2/Java to consume web services. In particular, I'm trying to generate Java skeleton code from a WSDL file.

    I installed the libaxis-java package, but the package doesn't contain the WSDL2Java.sh script I was expecting. I tried to generate the Java code by doing:

    java -cp /usr/share/java/axis.jar org.apache.axis.wsdl.WSDL2Java foo.wsdl
    

    But I get the following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
            at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:45)
            at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
            at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
            at org.apache.axis.i18n.ProjectResourceBundle.<clinit>(ProjectResourceBundle.java:53)
            at org.apache.axis.i18n.MessagesConstants.<clinit>(MessagesConstants.java:32)
            at org.apache.axis.utils.Messages.<clinit>(Messages.java:36)
            at org.apache.axis.wsdl.WSDL2Java.<clinit>(WSDL2Java.java:112)
    Could not find the main class: org.apache.axis.wsdl.WSDL2Java. Program will exit.
    
    • suhridk
      suhridk over 13 years
      Looks like you're missing a jar on the classpath.