0

I'm new to web service and AXIS2.

I downloaded and installed axis2-1.6.2-bin.zip in C:\Apache\axis2-1.6.2-bin I followed the instruction at http://axis.apache.org/axis2/java/core/docs/quickstartguide.html to generate the WSDL file. i.e. in the C:\Apache\axis2-1.6.2-bin\axis2-1.6.2\samples\quickstart directory, I ran ant generate.wsdl

I got the error: "org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed."

I searched my system and found that the only jar that contains 'org.apache.commons.logging.Log' class is in C:\Apache\axis2-1.6.2-bin\axis2-1.6.2\lib\commons-logging-1.1.1.jar. Any idea what cause this error and how to fix this? Any work around for the problem?

Seem like this is a bug according to http://jira.codehaus.org/browse/MSITE-459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=237414#action_237414

jbr
  • 6,198
  • 3
  • 30
  • 42
  • I am not sure why you chose AXIS, but here is a list of good reasons why not to use it:http://stackoverflow.com/questions/3588616/java-webservice-client-best-way. For creating a service, you just need to annotate a class with WebService and have WebMethods. and then publish it to server. to create clinet wsimport which comes along with jdk should do good. here is an example: http://java.dzone.com/articles/jax-ws-hello-world – Balaji Krishnan Oct 05 '13 at 02:04
  • @balajikrishnan Personally I've used Axis2 with great success. It's approach using ANT was better suited to my particular usecase. – Mark O'Connor Oct 05 '13 at 09:53

1 Answers1

0

The Jira link you quote is related to Maven and therefore has no relevance. I suspect your issue is related to your ANT environment.

Have you placed jars in one of the following locations?

  • $ANT_HOME/lib
  • $HOME/.ant/lb

These will be automatically added to your classpath and could cause this reported class clash. A good way to investigate classpath problems is to run ANT in debug and/or diagnostics mode.

ant generate.wsdl -diagnostics

Will include a report of what jars and where are loaded by ANT.

Working Example

Using ANT 1.9.0

$ ant -version
Apache Ant(TM) version 1.9.0 compiled on March 5 2013

I extracted the quickstart project from the downloaded axis2 distribution

$ cp -r $AXIS2_HOME/samples/quickstart .
$ tree
.
└── quickstart
    ├── build.xml
    ├── README.txt
    ├── resources
    │   └── META-INF
    │       └── services.xml
    └── src
        └── samples
            └── quickstart
                └── service
                    └── pojo
                        └── StockQuoteService.java

Running the

$ ant -f quickstart/build.xml generate.wsdl -DAXIS2_HOME=$AXIS2_HOME
Buildfile: /home/mark/tmp/quickstart/build.xml

compile.service:
    [mkdir] Created dir: /home/mark/tmp/quickstart/build
    [mkdir] Created dir: /home/mark/tmp/quickstart/build/classes
    [javac] /home/mark/tmp/quickstart/build.xml:42: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /home/mark/tmp/quickstart/build/classes
    [javac] Note: /home/mark/tmp/quickstart/src/samples/quickstart/service/pojo/StockQuoteService.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.

generate.wsdl:
[java2wsdl] log4j:WARN No appenders could be found for logger (org.apache.axis2.util.Loader).
[java2wsdl] log4j:WARN Please initialize the log4j system properly.

BUILD SUCCESSFUL
Total time: 2 seconds

Produces the expected files

$ tree
.
├── build
│   └── StockQuoteService.wsdl
└── quickstart
    ├── build
    │   └── classes
    │       └── samples
    │           └── quickstart
    │               └── service
    │                   └── pojo
    │                       └── StockQuoteService.class
    ├── build.xml
    ├── README.txt
    ├── resources
    │   └── META-INF
    │       └── services.xml
    └── src
        └── samples
            └── quickstart
                └── service
                    └── pojo
                        └── StockQuoteService.java

The ANT debug output shows the AXIS2 commons-logging jar being used:

$ ant -f quickstart/build.xml generate.wsdl -DAXIS2_HOME=$AXIS2_HOME -debug | grep "org/apache/commons/logging"
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogFactory.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogConfigurationException.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogFactory$6.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/WeakHashtable.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogFactory$1.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/WeakHashtable$Referenced.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/WeakHashtable$WeakKey.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogFactory$4.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogFactory$3.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/LogFactory$2.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/LogFactoryImpl.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/LogFactoryImpl$2.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/LogFactoryImpl$1.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/impl/Log4JLogger.class
Loaded from /opt/axis2-1.6.2/lib/commons-logging-1.1.1.jar org/apache/commons/logging/Log.class
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185