I have slf4j 1.6.1 with Log4j 1.2.16 included in my maven depedencies. It used to work fine in previous projects. However, recently I started a new project by reusing some of the previous code base, and then I started to have some weird issues.
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>1.4.1</version>
</dependency>
Basically what happened is that somehow slf4j-log4j13 is also included into the war file, most likely thru some transitive dependency relationships of some other dependencies. However, when I used "mvn dependency:tree" to check the transitive dependencies, I didn't find "slf4j-log4j13".
The result is tricky. I have both slf4j-log4j12 and slf4j-log4j13 in my war file. Surprisingly it worked fine on my Mac OSX system, somehow. By working fine, I mean there are no any conflicts, exceptions or errors caused by it. However, when I deploy it to another Linux (Ubuntu) 64-bit machine, it gave me troubles. The exception is as follows,
'xmlResponseParser' while setting bean property 'parser'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xmlResponseParser' defined in ServletContext resource [/WEB-INF/spring/spring-solr.xml]: Instantiation of bean failed; nested exception is java.lang.NoSuchMethodError: org.apache.log4j.Logger.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V
(Stack trace ignored)
Looks like xmlResponseParser is using slf4j but could not find log4j dependency. Is this caused by the conflicts between slf4j-log4j12 and slf4j-log413? Why does it happen only on Linux?
I tried to remove one of them; however, removing either of them causes problems. I'd like to see if anyone had similar experiences.