SOLVED: My class resource was named TestCounter... maven was trying to test it. Renamed it to CounterSwitch and build was successful.
I'm very new to maven, please bear with me... I have some tests that run great in eclipse, but fail during a maven build.
The tests are in: src/test/java/main/*.java
The tests use test-only classes in: src/test/java/**/*.java
The tests also require access to resources located in: src/test/resources/packages/etc...
Within my resources are .java source files that I am not compiling, but am using for JaCoCo analysis tests. I'm loading these resources using relative pathed File objects since resource loader insists on using absolute pathing and causes my tests to fail.
Common sense says that the relative pathing changes post-build and that's why maven's throwing NoClassDefFoundError, but it's also throwing the exception when it encounters one of the .java files... it may be trying to compile it or it may just be a coincidence.
However, the solution may be more convenient as it is not necessary for me to run these tests during the maven lifecycle, they're functional tests that are used more for the results they produce and less for their assertions but I have no idea how to blacklist them.
I have two questions: how do I segregate those files from my maven build that are undesirable, and how do I include those files into my maven build that are?
I'd appreciate any help I can get... here's a relevant representation of my pom.xml (plugins make it quite lengthy) for reference, it's almost a default configuration as I have no idea where to begin with it:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.genericpackage</groupId>
<artifactId>genericartifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>genericartifact</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Stack Trace:
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.NoClassDefFoundError: mockprocesses/itclient-counter/bin/main/TestCounter (wrong name: main/TestCounter)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:98)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:78)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:174)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:83)
... 9 more
Fixed it, the problem was obvious... the class/java files were named TestCounter... surefire was trying to test them. Renamed them to CounterSwitch and the build went off without a hitch.
Had same issue, fixed it including the file as part of maven-surefire-plugin configuration, as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>src/main/java/mockprocesses/itclient-counter/bin/main/TestCounter.java</include>
</includes>
</configuration>
</plugin>
Related
I have tried to include all the jars needed in Referenced Libraries.
There are similar questions on this forum, I have gone through all but unable to resolve the issue.
My Code Snippet:
Workbook workbook = new XSSFWorkbook();
CreationHelper createHelper = workbook.getCreationHelper();
Sheet sheet = workbook.createSheet("Gene");
Font headerFont = workbook.createFont();
All the jars that I am using
I am getting following errors:
Exception stack trace:
org.apache.poi.ooxml.POIXMLException: org.apache.poi.ooxml.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:602)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.createSheet(XSSFWorkbook.java:896)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.createSheet(XSSFWorkbook.java:807)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.createSheet(XSSFWorkbook.java:122)
at DomParser.main(DomParser.java:18)
Caused by: org.apache.poi.ooxml.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.ooxml.POIXMLFactory.newDocumentPart(POIXMLFactory.java:111)
at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:587)
... 4 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
at org.apache.poi.ooxml.POIXMLFactory.newDocumentPart(POIXMLFactory.java:109)
... 5 more
Caused by: java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl.generatedSetterHelperImpl(Lorg/apache/xmlbeans/XmlObject;Ljavax/xml/namespace/QName;IS)Lorg/apache/xmlbeans/XmlObject;
at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl.setColsArray(Unknown Source)
at org.apache.poi.xssf.usermodel.helpers.ColumnHelper.cleanColumns(ColumnHelper.java:66)
at org.apache.poi.xssf.usermodel.helpers.ColumnHelper.<init>(ColumnHelper.java:46)
at org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentCreate(XSSFSheet.java:259)
at org.apache.poi.xssf.usermodel.XSSFSheet.<init>(XSSFSheet.java:187)
... 11 more
You need to use xmlbeans-3.0.1 instead of xmlbeans-5.1.3.
Starting from the error, which was:
Caused by: java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl.generatedSetterHelperImpl(Lorg/apache/xmlbeans/XmlObject;Ljavax/xml/namespace/QName;IS)Lorg/apache/xmlbeans/XmlObject;
I searched the Maven Central Repository for jars containing the class CTWorksheetImpl:
https://search.maven.org/search?q=fc:org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl
The answer was poi-ooxml-schemas, which you already had, and was the same version as poi. Seemed OK. Then I thought it had to be the method itself. The parameters were from the org.apache.xmlbeans package, so the xmlbeans version was probably wrong.
How can you find out the right version?
Rather than gathering jar files manually, you may want to try Maven for dependency management. In a Maven project, it would be enough to say you want poi-ooxml. This would automatically bring in all the dependencies, recursively, with the right versions.
This is an example Maven pom.xml file you could use your project:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>poi-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Even if you don't want to (or can't) use Maven in your project, you could at least do a separate project just for finding out the dependencies, like I did.
I have created a sample plugin application using RCP framework using Hello RCP framework. Then, I converted the project into Maven project in "configure" option. I need a mysql connector to perform some db operation; for that I have added the dependencies in the pom.xml file.
After building the application, it's able to create the maven dependency folder and put the required mysql jars. However, when I run the application it says its not able to find the Driver class. There is no error in the jar file which is there in Maven Dependency folder. If I manually put it in the build path its working fine.
Whenever I create a sample JAVA application and convert it into maven project and add these dependencies its working fine. Only for plug in project its not able to locate the jars required.
Below is the content 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample.plugin</groupId>
<artifactId>com.sample.plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
<scope>Compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
//Error message
Inside the connection class1:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Error: unable to load driver class!
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.sample.plugin.DButil.getConnection(DButil.java:25)
at com.sample.plugin.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Picked up _JAVA_OPTIONS: -Xmx512M
Download mySQL jdbc driver, if not already done
Add this to your local repository (Due to licensing issues, you must download, you cannot download it from Maven public repository)
Make sure you mark the dependency as runtime, since we do not require driver jar during compile. Javac compiles to the JDBC API interfaces.
Currently my NetBeans 8.0 has been doing the strangest thing.
I have a multimodule project. Usually I did not even have to have the projects opened or even downloaded, if the modules were in maven repository. Currently, some of my modules however need to be opened and built, so that "target" folder is in the project directory filled with classes. If it is not, I get a NoClassDefFoundError.
The error looks like this:
Exception in thread "main" java.lang.NoClassDefFoundError: SOME/CLASS/THAT/IS/EXPECTED/IN/TARGET/FOLDER/OF/SOME/MODULE/THAT/IS/A/DEPENDENCY
at ...
Caused by: java.lang.ClassNotFoundException: com.example.SOME.CLASS.THAT.IS.EXPECTED.IN.TARGET.FOLDER.OF.SOME.MODULE.THAT.IS.A.DEPENDENCY
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
My POM looks like this:
<parent>
<groupId>some</groupId>
<artifactId>parent</artifactId>
<version>0.9-SNAPSHOT</version>
</parent>
<scm>
<developerConnection>scm:svn:https://someconnection</developerConnection>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagBase>sometagbase/tags</tagBase>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>myModuleGroupId</groupId>
<artifactId>somModule1</artifactId>
<version>1.2.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
...... many of these here
</dependencies>
Why does it suddenly require a target folder with classes? Is it not supposed to get them from the dependencies? From the repository?
Open maven tab at right side of the editor and run double click all options of life cycle and try to see if folder finally generated
I recently discovered Cargo and am really excited about its potential for allowing developers to consistently and automatically test web artifacts using maven -- but I am having trouble getting it configured correctly. For better or worse, we are a WebLogic shop, but I have been unable to find a good example of configuring a WebLogic Local Standalone using Cargo's Maven plugin, as the plugin is unable to find the org.codehaus.cargo.container.weblogic.WebLogic103xStandaloneLocalConfiguration class.
To simplify things, I started with the archetype (which includes samples for ever server EXCEPT weblogic....gee thanks) and changed the plugin under pluginManagement to look like this:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<configuration>
<container>
<containerId>weblogic103x</containerId>
<type>standalone</type>
<home>${weblogic.10.3.server}</home>
</container>
<configuration>
<type>local</type>
<properties>
<cargo.servlet.port>8001</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
Some of this may be redundant (I'm not very experienced with maven profiles), but I also added an additional profile and made it default:
<profile>
<id>weblogic103x</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<configuration>
<container>
<containerId>weblogic103x</containerId>
<type>standalone</type>
<home>${weblogic.10.3.server}</home>
</container>
<configuration>
<type>local</type>
<implementation>org.codehaus.cargo.container.weblogic.WebLogic103xStandaloneLocalConfiguration</implementation>
<properties>
<cargo.servlet.port>8001</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
And the exception I get is:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Custom configuration implementation [org.codehaus.cargo.container.weblogic.WebLogic103xStandaloneLocalConfiguration] cannot be loaded
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Custom configuration implementation [org.codehaus.cargo.container.weblogic.WebLogic103xStandaloneLocalConfiguration] cannot be loaded
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
[snip]... several more
Caused by: org.apache.maven.plugin.MojoExecutionException: Custom configuration implementation [org.codehaus.cargo.container.weblogic.WebLogic103xStandaloneLocalConfiguration] cannot be loaded
at org.codehaus.cargo.maven2.configuration.Configuration.createConfiguration(Configuration.java:266)
[snip]... several more
Caused by: java.lang.ClassNotFoundException: org.codehaus.cargo.container.weblogic.WebLogic103xStandaloneLocalConfiguration
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at org.codehaus.cargo.maven2.configuration.Configuration.createConfiguration(Configuration.java:259)
... 24 more
Am I just missing some setting? Or am I fundamentally misunderstanding how Cargo is supposed to work? Or something else?
OK, I got it. This was occurring because I had specified an implementation class in the profile. Once that was removed, the error was:
There's no registered configuration for the parameters (container [id = [weblogic103x], type = [standalone]], configuration type [local]).
This is of course because I needed to pay closer attention to exactly the which values are allowed which type field -- Container type vs Configuration type. This page has the reference:
http://cargo.codehaus.org/Maven2+Plugin+Reference+Guide
Once I got the container type to "installed" and the configuration type to "standalone", things went much more smoothly.
So, RTFM on me! :)
I have a maven project with unit tests, and I get a large exception trace when running "mvn install". Surprisingly -- this stacktrace actually doesn't result in failure of the task ! It appears that it is related to the availability of Junit libraries...
1) Id like to know how to fix this (obviously) for this project so that the libraries are available and the tests run (yes, Junit4 is in the pom.xml dependencies).
2) What the best way to definitively debug this and find the root cause is ?
3) Why does Maven say "build success" when clearly the surefire utility threw a nasty exception ?
org.apache.maven.surefire.util.SurefireReflectionException:
java.lang.reflect.InvocationTargetException; nested exception is
java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException 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:597) at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
Caused by: java.lang.NoClassDefFoundError: Test at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at
java.lang.Class.getMethod0(Class.java:2670) at
java.lang.Class.getMethod(Class.java:1603) at
org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(ReflectionUtils.java:57)
at
org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly(JUnit3TestChecker.java:65)
at
org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUnit3Test(JUnit3TestChecker.java:60)
at
org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUnit3TestChecker.java:55)
at
org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:52)
at
org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:80)
at
org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:174)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:83)
... 9 more Caused by: java.lang.ClassNotFoundException: Test at
java.net.URLClassLoader$1.run(URLClassLoader.java:202) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:190) at
java.lang.ClassLoader.loadClass(ClassLoader.java:306) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at
java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 21 more
POM is below
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rudolf</groupId>
<artifactId>r1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>r1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.9.1.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.4.0a</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>onejar-maven-plugin.googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
</project>
This is definetly a perfect storm of silliness:
1) My Test Classes is not named according to the default surefire regular expressions See related Maven does not find JUnit tests to run. So the tests weren't really running.
2) The Test that DID run was actually doing some JVM hacking, using classes like "Unsafe" - causing a segmentation fault. This segmentation fault mucks with the overall Maven build, corrupting the result of the maven output.
The take home lessons are:
1) (not 100% sure, but it appears ) -- If some odd low level failure occurs in the JVM during a mvn build, one might expect strange results at the end which dont simply indicate errors/failures in the proper manner
2) Default Junit test case for surefire behaviour doesnt just run all #Test methods in a package automatically - classes have to be named appropriately or you have to manually edit the surefire pattern filters.
I've run into a problem like this with TestNG integration tests (fail-safe). A similarly really cryptic error caused me to lose an entire day (argh! - please, Eclipse/TestNG, if you're going to give us errors, make them helpful). In my case it was because the accessor on the test method was private and needed to be public.
I hope someone else find this useful before an entire day is wasted.