Lucas Bergman wrote:
> I ran into a strange dependency resolution problem at work, which a
> colleague and I whittled down to a fairly simple test case. Consider
> the following POM:
>
> <project xmlns="
http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0>
http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.example</groupId>
> <artifactId>htmlunitbug</artifactId>
> <packaging>jar</packaging>
> <version>2.71828</version>
>
> <build>
> <pluginManagement>
> <plugins>
> <plugin>
> <artifactId>maven-compiler-plugin</artifactId>
> <configuration>
> <source>1.5</source>
> <target>1.5</target>
> </configuration>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>4.6</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>net.sourceforge.htmlunit</groupId>
> <artifactId>htmlunit</artifactId>
> <version>2.5</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>org.hibernate</groupId>
> <artifactId>hibernate-ehcache</artifactId>
> <version>3.3.1.GA</version>
> <scope>runtime</scope>
> </dependency>
> <!-- hibernate-ehcache depends on a very old version. -->
> <dependency>
> <groupId>net.sf.ehcache</groupId>
> <artifactId>ehcache</artifactId>
> <version>1.6.0</version>
> <scope>runtime</scope>
> </dependency>
> </dependencies>
> </project>
>
> And, consider the following test class:
>
> import com.gargoylesoftware.htmlunit.WebClient;
> import org.junit.Test;
>
> public class MyTest {
> @Test public void test() { new WebClient(); }
> }
>
> Running this test with Maven 2.1.0 fails:
>
> java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
> [ ... ]
>
> The POM for htmlunit 2.5 declares commons-logging 1.1.1 as a
> (compile-scope) dependency, so this seems wrong. There seems to be
> some interaction between that POM and the dependent POMs.
By default commons-logging tries to discover the logger in use on its own.
Somehow a log4j is available from somewhere else, but the classpath does
not match. Therefore disable the discovery by either providing a
commons-logging.properties file in src/test/resources or set a system
property in the surefire configuration for your tests.
See
http://commons.apache.org/logging/commons-logging-1.1.1/guide.html#Configuration- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...