开发者

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?


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>


Upgrade to version 1.3 solved the problem.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜