yegor256
yegor256

Reputation: 105063

How to resolve Groovy conflict with Apache Common Logging?

This is my custom maven Groovy execution:

[...]
<plugin>
  <groupId>org.codehaus.groovy.maven</groupId>
  <artifactId>gmaven-plugin</artifactId>
  <version>1.0-rc-5-SNAPSHOT</version>
  <executions>
    <execution>
      <phase>prepare-package</phase>
      <goals>
        <goal>execute</goal>
      </goals>
      <configuration>
        <classpath>
          <element>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
          </element
        </classpath>
        <source>
          import org.apache.commons.httpclient.HttpClient;
          // ...
        </source>
      </configuration>
    </execution>
  </executions>
</plugin>
[...]

This is what Maven says:

[...]
[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0-rc-5-SNAPSHOT:execute (...) on project XXX: 
java.lang.ExceptionInInitializerError: org.apache.commons.logging.LogConfigurationException:
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. 
(Caused by org.apache.commons.logging.LogConfigurationException: 
Invalid class loader hierarchy.
[...]

I think that I understand why it happens, but how can I solve it?

Upvotes: 0

Views: 1316

Answers (3)

yegor256
yegor256

Reputation: 105063

Upgrade to version 1.3 solved the problem.

Upvotes: 1

Alexis
Alexis

Reputation: 406

Check who is importing that dependency with mvn dependency:tree and remove conflict.

Upvotes: 0

dsummersl
dsummersl

Reputation: 6727

Its hard to say exactly how to fix this without seeing your entire pom.xml file, but I'd suggest looking into the tag. You could exclude the extra dependency with something like the following:

<plugin>
    ...
    ...
    <dependencies>
        <dependency>
            <artifactId>...</artifactId>
            <groupId>...</groupId>
            <version>...</version>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>                        
                <exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</plugin>

Upvotes: 1

Related Questions