stefan.m
stefan.m

Reputation: 2012

commons-logging-api-1.1.jar vs. commons-logging-1.2.jar

I am doing a very simple Proof of Concept of a 3rd party library (in this case, solrj).

Although I am using maven as a build system, I get the error

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

as solrj (4.10.4) doesn't define it as a dependency.

I therefore can now manually add commons logging as a maven dependency, but I am unsure which one to add:

The programs runs successfully, no matter which of the two I add.

My questions:

Upvotes: 3

Views: 3010

Answers (1)

Ed Randall
Ed Randall

Reputation: 7570

The commons-logging-api is just a set of interfaces to which the code (Solr in this case) is compiled, without 'locking in' to any particular logging implementation. It is unlikely to have changed at all since 1.1 so the maven vector for it remains unchanged at 1.1. But it's included with the 1.2 bundle anyway so you don't need it. All you need is:

  • commons-logging:commons-logging:1.2

It's possible (likely) that some other dependency in your project is dependent on commons-logging also, hence maven will pick this up and you find that the project works either way. You can see the hierarchy of dependencies it's pulling in using:

mvn dependency:tree

You can also configure commons-logging to use an alternate underlying log system implementation eg. Log4J. It would be worth reading the commons-logging user guide to learn how it works and what you can do to tune it to your requirements.

Upvotes: 2

Related Questions