April 15, 2007

Maven 2 Build Error

Here are the details on the build error I'm having in Maven 2.0.6

alex@Apollonius ~/projects/arete/arete-all/arete-core
$ mvn test
[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------------
---
[INFO] Building arete-core
[INFO]    task-segment: [test]
[INFO] -------------------------------------------------------------------------
---
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Setting reports dir: c:\dev\projects\arete\arete-all\arete-core\target/su
refire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[surefire] Running org.eremite.arete.core.CorePerformanceTest
[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.04 sec
[surefire] Running org.eremite.arete.core.HypothesisAPITest
[surefire] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0 sec
[surefire] Running org.eremite.arete.core.HypothesisBootstrapTest
[surefire] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.08 sec <<<<<<<<
 FAILURE !!
w00t!  Gotta love PicoContainer.
w00t!  Gotta love PicoContainer.
w00t!  Gotta love PicoContainer.
[surefire] Running org.eremite.arete.core.PicoContainerTest
[surefire] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.01 sec
[surefire] Running org.eremite.arete.core.SerializationTest
[surefire] Tests run: 4, Failures: 0, Errors: 4, Time elapsed: 0.2 sec <<<<<<<<
FAILURE !!
java.io.BufferedInputStream@a77106
java.io.BufferedInputStream@1e1dadb
[surefire] Running org.eremite.arete.core.throughput.ThroughputTest
[surefire] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.02 sec <<<<<<<<
 FAILURE !!
[surefire] Running org.eremite.arete.core.wrappers.WrapperFactoryTest
[surefire] Tests run: 4, Failures: 0, Errors: 4, Time elapsed: 0.02 sec <<<<<<<<
 FAILURE !!
[surefire] Running org.eremite.arete.examples.baseball.BaseballTest
[surefire] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.03 sec <<<<<<<<
 FAILURE !!

Results :
[surefire] Tests run: 20, Failures: 0, Errors: 14

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] There are some test failure.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Sun Apr 15 13:25:24 CDT 2007
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------

This is one of my surefire reports. It is reporting a NoClassDefFoundError.

java.lang.NoClassDefFoundError: org/eremite/arete/core/Premise
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
	at org.eremite.arete.core.PremiseFactory$DirectLoader.load(PremiseFactory.java:221)
	at org.eremite.arete.core.PremiseFactory.getPremise(PremiseFactory.java:73)
	at org.eremite.arete.core.HypothesisBootstrapTest.testPremiseRegistration(HypothesisBootstrapTest.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
. . . 

Here is the source of my pom.xml

<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>org.eremite.arete</groupId>
  <artifactId>arete-core</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT-05</version>
  <name>arete-core</name>
  <url>http://sf.net/projects/arete</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>picocontainer</groupId>
      <artifactId>picocontainer</artifactId>
      <version>1.1</version>
    </dependency>

    <!-- dependency>
      <groupId>org.eremite.arete</groupId>
      <artifactId>arete-core</artifactId>
      <version>1.0-SNAPSHOT-04</version>
      <scope>test</scope>
    </dependency-->
  </dependencies>

  <build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <directory>target</directory>
    <outputDirectory>target/classes</outputDirectory>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <finalName>${artifactId}-${version}</finalName>

    <testResources>
      <testResource>
        <directory>src/test/etc</directory>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.properties</include>
        </includes>
      </testResource>
    </testResources>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>false</skip>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Here is my file structure:

alex@Apollonius ~/projects/arete/arete-all/arete-core
$ ls -R src
src:
main  test

src/main:
java

src/main/java:
org

src/main/java/org:
eremite

src/main/java/org/eremite:
arete

src/main/java/org/eremite/arete:
core  io

src/main/java/org/eremite/arete/core:
AlphaCore.java           DefaultEngine.java                HypothesisInfo.java
ComponentArchive.java    DefaultHypothesisComparator.java  Premise.java
Consequence.java         Engine.java                       PremiseFactory.java
ConsequenceFactory.java  EngineFactory.java                PremiseInfo.java
ConsequenceInfo.java     Hopper.java
Core.java                Hypothesis.java

src/main/java/org/eremite/arete/io:
UnsupportedSyntaxException.java  XMLReader.java

src/test:
etc  java

src/test/etc:
org

src/test/etc/org:
eremite

src/test/etc/org/eremite:
arete

src/test/etc/org/eremite/arete:
core  examples

src/test/etc/org/eremite/arete/core:
aporetics  throughput  wrappers

src/test/etc/org/eremite/arete/core/aporetics:
aporetics.xml

src/test/etc/org/eremite/arete/core/throughput:
throughput.xml

src/test/etc/org/eremite/arete/core/wrappers:

src/test/etc/org/eremite/arete/examples:
baseball

src/test/etc/org/eremite/arete/examples/baseball:
baseball.xml

src/test/java:
org

src/test/java/org:
eremite

src/test/java/org/eremite:
arete

src/test/java/org/eremite/arete:
core  examples

src/test/java/org/eremite/arete/core:
CorePerformanceTest.java      PicoContainerTest.java  throughput
HypothesisAPITest.java        SerializationTest.java  wrappers
HypothesisBootstrapTest.java  aporetics

src/test/java/org/eremite/arete/core/aporetics:
aporetics.xml

src/test/java/org/eremite/arete/core/throughput:
CountMonitor.java  CountingActions.java  throughput.xml
Counter.java       ThroughputTest.java

src/test/java/org/eremite/arete/core/wrappers:
AbstractConsequence.java  Student.java
AbstractPremise.java      WrapperFactoryTest.java

src/test/java/org/eremite/arete/examples:
baseball

src/test/java/org/eremite/arete/examples/baseball:
BaseballTest.java  Cup.java    Juice.java   PlayerActions.java  baseball.xml
CoachActions.java  Fruit.java  Player.java  PlayerMonitor.java

I have read--scoured, really--the Maven 2.0 documentation, Google, read several articles on building the POM.xml, and have found nothing to help me answer this. I even manually copied the .class files from my target/classes into my target/test-classes directory to see if that would help. It did not. For some reason, the test classes are not seeing the main classes.

My build works fine in maven 1.3 and in IntelliJ IDEA. I must have something wrong in my pom.xml

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.