trautonen / coveralls-maven-plugin

Maven plugin for submitting Java code coverage reports to Coveralls web service.
MIT License
312 stars 123 forks source link

User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable. #74

Closed tmoreira2020 closed 9 years ago

tmoreira2020 commented 9 years ago

Hi there, I'm trying to run the plugin in a multi module project and I faced to following problem. I got it fixed adding log4j-1.2.7 as a dependency for the plugin. What I think is happening is that a previous plugin is using commons-logging with log4j and it is not cleaning up the mess. The project with the problem is https://github.com/tmoreira2020/portal-properties-prettier-app whit sha aaebe7da31b1a4ff0560a43584975c35f872d9bb

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:3.1.0:report (default-cli) on project portal-properties-prettier-app-parent: Execution default-cli of goal org.eluder.coveralls:coveralls-maven-plugin:3.1.0:report failed: An API incompatibility was encountered while executing org.eluder.coveralls:coveralls-maven-plugin:3.1.0:report: java.lang.ExceptionInInitializerError: null [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.eluder.coveralls:coveralls-maven-plugin:3.1.0 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/Users/tmoreira2020/.m2/repository/org/eluder/coveralls/coveralls-maven-plugin/3.1.0/coveralls-maven-plugin-3.1.0.jar [ERROR] urls[1] = file:/Users/tmoreira2020/.m2/repository/org/apache/httpcomponents/httpclient/4.3.5/httpclient-4.3.5.jar [ERROR] urls[2] = file:/Users/tmoreira2020/.m2/repository/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar [ERROR] urls[3] = file:/Users/tmoreira2020/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar [ERROR] urls[4] = file:/Users/tmoreira2020/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar [ERROR] urls[5] = file:/Users/tmoreira2020/.m2/repository/org/apache/httpcomponents/httpmime/4.3.5/httpmime-4.3.5.jar [ERROR] urls[6] = file:/Users/tmoreira2020/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.2/jackson-core-2.4.2.jar [ERROR] urls[7] = file:/Users/tmoreira2020/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.4.2/jackson-annotations-2.4.2.jar [ERROR] urls[8] = file:/Users/tmoreira2020/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.2/jackson-databind-2.4.2.jar [ERROR] urls[9] = file:/Users/tmoreira2020/.m2/repository/org/eclipse/jgit/org.eclipse.jgit/3.4.1.201406201815-r/org.eclipse.jgit-3.4.1.201406201815-r.jar [ERROR] urls[10] = file:/Users/tmoreira2020/.m2/repository/com/jcraft/jsch/0.1.50/jsch-0.1.50.jar [ERROR] urls[11] = file:/Users/tmoreira2020/.m2/repository/com/googlecode/javaewah/JavaEWAH/0.7.9/JavaEWAH-0.7.9.jar [ERROR] urls[12] = file:/Users/tmoreira2020/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.7/plexus-utils-2.0.7.jar [ERROR] urls[13] = file:/Users/tmoreira2020/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.3.2/sisu-inject-bean-1.4.3.2.jar [ERROR] urls[14] = file:/Users/tmoreira2020/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.2/sisu-guice-2.9.2-no_aop.jar [ERROR] urls[15] = file:/Users/tmoreira2020/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar [ERROR] urls[16] = file:/Users/tmoreira2020/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar [ERROR] urls[17] = file:/Users/tmoreira2020/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar [ERROR] urls[18] = file:/Users/tmoreira2020/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar [ERROR] urls[19] = file:/Users/tmoreira2020/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar [ERROR] urls[20] = file:/Users/tmoreira2020/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] -----------------------------------------------------: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable. [ERROR] -> [Help 1]

trautonen commented 9 years ago

Something in your build is messing up the dependencies indeed. Coveralls maven plugin does not have a dependency to log4j, it only uses the Maven internal logger.

I couldn't figure with quick debugging what's causing dependency problem, but my guess is that some plugin loads a messy transitive dependency that blows up or there's some other maven plugin that screws up the reactor build dependencies. This is black magic. Hard to debug because depency:analyze can't do much with maven plugins.

There's a workaround though. You can run the build in two stages. First run cobertura:cobertura, and then run only the coveralls:report goal. This way the maven lifecycle does not trigger by cobertura and coveralls:report runs in clean environment where other lifecycle plugins cannot mess with the dependencies.

So you can remove the log4j dependecy and change your travis after_success in two steps:

- mvn clean cobertura:cobertura
- mvn coveralls:report

Not the most elegant solution, but does the job unless you can figure out what's causing the log4j to pop up.

trautonen commented 9 years ago

I created a new snapshot build which removes the apache httpclient commons-logging dependency via slf4j bridge. If the cause is some other plugin binding commons-logging to log4j this change might help, or might not. But you can try the 3.2.0-SNAPSHOT from sonatype's repo.

trautonen commented 9 years ago

I just ran build of your project with the 3.2.0-SNAPSHOT and I think the removal of commons-logging and changing it with slf4j bridge did the trick. Could you also verify this?

I cloned your repo, built it. Changed your parent.pom in my local maven repo and changed coveralls plugin version and removed the log4j dependency.

trautonen commented 9 years ago

@tmoreira2020 did you try with the latest snapshot?

trautonen commented 9 years ago

Fixed according to own tests.