I've been following a PluralSight course on JavaEE using eclipse and maven. I'm currently trying to write some tests, but when running mvn package
from the cmd line I've been getting this error:
Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
Sometimes it refers to:
java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener
and sometimes:
java.lang.NoClassDefFoundError: org/junit/runner/Description
I've done a bit of reading around and RunListener seems to have been introduced in JUnit 4.0. But as far as I can tell I have the correct dependency - JUnit 4.12 is in my dependency hierarchy. And I've now changed all my files to the Exercise files in order to trouble shoot this.
I'm guessing that maybe I've fundamentally misunderstood how maven and dependencies work, RE jars and the classpath, and that I still need to point eclipse or the cmd line to the JUnit jar? (I get the same errors in both). I just find that odd given that other JUnit classes are recognised in my java objects. Here's my (pluralsight's) pom anyway:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pluralsight.javaee-getting-started.javaee-getting-started-m6</groupId>
<artifactId>bookstore-back</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>Getting Started :: javaee-getting-started-m6 :: Testing the Repository :: Back</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Test -->
<version.junit>4.12</version.junit>
<version.arquillian>1.1.13.5</version.arquillian>
<version.arquillian.wildfly>2.0.2.Final</version.arquillian.wildfly>
<version.shrinkwrap>1.2.6</version.shrinkwrap>
<!-- Plugins -->
<version.surefire.plugin>2.19.1</version.surefire.plugin>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.arquillian</groupId>
<artifactId>arquillian-universe</artifactId>
<version>${version.arquillian}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- TEST -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.arquillian.universe</groupId>
<artifactId>arquillian-junit</artifactId>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>${version.shrinkwrap}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>${version.arquillian.wildfly}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>bookstore-back</finalName>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<configuration>
<systemPropertyVariables>
<arquillian.launch>arquillian-wildfly-remote</arquillian.launch>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>src</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Am I on the right track with the classpath idea?