common logging jar conflict with apache axis soap client

The Link to the above mentioned Documentation to section "Fixes" suggests to include

 -Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl

in your setup. For some people it might be easier to include this code instead:

static
{
    System.setProperty(LogFactory.FACTORY_PROPERTY, LogFactory.FACTORY_DEFAULT);
}

There is a pretty detailed explanation of what the issue may be and ways to debug it in the commons logging documentation. Your particular issue may be,

There is also another more unusual way in which this cast can fail: even when the binary is compatible, the implementation class loaded at runtime may be linked to a different instance of the LogFactory class. For more information, see the tech guide.


None of this solutions worked for me. I figure out my solution in SLF4J documentation

http://slf4j.org/faq.html#excludingJCL

alternative 2) provided scope Commons-logging can be rather simply and conveniently excluded as a dependency by declaring it in the provided scope within the pom.xml file of your project. The actual commons-logging classes would be provided by jcl-over-slf4j. This translates into the following pom file snippet:

<dependency>  
   <groupId>commons-logging</groupId>  
   <artifactId>commons-logging</artifactId>
   <version>1.1.1</version>  
   <scope>provided</scope>
</dependency> 

<dependency>
   <groupId>org.slf4j</groupId>  
   <artifactId>jcl-over-slf4j</artifactId>
   <version>1.7.21</version>
</dependency>

The first dependency declaration essentially states that commons-logging will be "somehow" provided by your environment. The second declaration includes jcl-over-slf4j into your project. As jcl-over-slf4j is a perfect binary-compatible replacement for commons-logging, the first assertion becomes true. Unfortunately, while declaring commons-logging in the provided scope gets the job done, your IDE, e.g. Eclipse, will still place commons-logging.jar on your project's class path as seen by your IDE. You would need to make sure that jcl-over-slf4j.jar is visible before commons-logging.jar by your IDE.

SLF4J documentation gives more alternatives, this worked for me.

Tags:

Java

Axis2