Uploading a File via SCP with Maven fails - maven-2

I try to upload an ear created by maven to an application server using scp.
When I tried to run
mvn wagon:upload-single
But I get the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload-single (default-cli) on project de.volkswagen.dps.ear: Unable to create a Wagon instance for null: url can not be null -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload-single (default-cli) on project de.volkswagen.dps.ear: Unable to create a Wagon instance for null
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:585)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to create a Wagon instance for null
at org.codehaus.mojo.wagon.AbstractWagonMojo.createWagon(AbstractWagonMojo.java:83)
at org.codehaus.mojo.wagon.AbstractSingleWagonMojo.execute(AbstractSingleWagonMojo.java:62)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
... 14 more
Caused by: java.lang.NullPointerException: url can not be null
at org.apache.maven.wagon.repository.Repository.(Repository.java:88)
at org.codehaus.mojo.wagon.shared.WagonUtils.createWagon(WagonUtils.java:51)
at org.codehaus.mojo.wagon.AbstractWagonMojo.createWagon(AbstractWagonMojo.java:79)
... 17 more
I tried to add this to the pom, but it doesn't seem to have any effect:
I added the following to the pom.xml:
...
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-ear</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromFile>${project.build.directory}/${project.build.finalName}.ear</fromFile>
<url>scp://servername/</url>
<toDir>.</toDir>
</configuration>
</execution>
</executions>
</plugin>
....
Can anybody explain how I can make this work?

Your current configuration follows the example given in the Usage page and is correct. However, in this example the configuration element is declared inside an execution and thus only applies to this particular execution.
So when you call mvn wagon:upload-single on the command line, the configuration isn't "used" and there is indeed no url parameter configured.
If you want to call the plugin from the command line, either pass the parameters on the command line using -Durl=foo and so on or add a "global" configuration element:
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<fromFile>${project.build.directory}/${project.build.finalName}.ear</fromFile>
<url>scp://servername/</url>
<toDir>.</toDir>
</configuration>
...
</plugin>
...
</plugins>
...
</build>

You can run the following command to run the plugin using the configuration on your pom.xml:
mvn org.codehaus.mojo:wagon-maven-plugin:upload#upload-ear

Related

Unable to load the mojo 'execute' in the gmaven-plugin plugin

I upgraded java-8 to java-11 and since then I got an error on gmaven-plugin:
Error injecting constructor, java.lang.ExceptionInInitializerError
at org.codehaus.groovy.maven.plugin.execute.ExecuteMojo.(Unknown Source)
while locating org.codehaus.groovy.maven.plugin.execute.ExecuteMojo
[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute (tmp-id) on project project-name: Execution tmp-id of goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute failed: Unable to load the mojo 'execute' in the plugin 'org.codehaus.groovy.maven:gmaven-plugin:1.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>tmp-id</id>
<phase>install</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
println 'Hello'
</source>
</configuration>
</execution>
</executions>
</plugin>
Any ideas?

Karate: Why NullPointerException at FileUtils happens for mvn clean-integration-test?

Our Karate Scripts for Integration Test works as expected when we use the cmd- mvn integration-test. if we use clean it fails with the below error and the successfully executed test not executing again.
Error log given below when we use the cmd - mvn clean integration-test
[INFO] --- maven-failsafe-plugin:2.13:integration-test (default) # formfill ---
[INFO] Failsafe report directory: D:\Baskaran\wvid-stash\formfill\target\failsafe-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.dnb.vici.formfill.it.FormFill_ITSuite
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.27 sec <<< FAILURE!
initializationError(com.dnb.vici.formfill.it.FormFill_ITSuite) Time elapsed: 0.008 sec <<< ERROR!
java.lang.NullPointerException: null
at com.intuit.karate.FileUtils.resolveIfClassPath(FileUtils.java:157)
at com.intuit.karate.cucumber.KarateFeature.<init>(KarateFeature.java:47)
at com.intuit.karate.cucumber.KarateFeature.loadFeatures(KarateFeature.java:62)
at com.intuit.karate.junit4.Karate.<init>(Karate.java:53)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
Our configuration in POM is given below for reference.
<!-- Following plugin executes the unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version><!--$NO-MVN-MAN-VER$ -->
</plugin>
<!-- Following plugin executes the integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.13</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<includes>
<include>**/FormFill_ITSuite.java</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
I encountered the same NullPointerException when I compiled my tests with JDK 1.7.0_75. Using 1.8.0_72 instead worked.
You say your tests work before and they stop working when using 'mvn clean'. Unfortunately you don't tell us how you got them working in the first place. But 'mvn clean' removes the existing artifacts and if they are then compiled again with an older JDK, the NullPointerException occurs.

How To Build Child Modules In Tycho

I have a multi-module Tycho build with a target definition file. The target definition is defined in it's own project (ID: org.acme.project.target, packaging type: pom) like this:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>platform_rcp.target</file>
<type>target</type>
<classifier>platform_rcp</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
And the Maven parent refers to this target platform like this:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<resolver>p2</resolver>
<target>
<artifact>
<groupId>${project.groupId}</groupId>
<artifactId>org.acme.project.target</artifactId>
<version>${project.version}</version>
<classifier>platform_rcp</classifier>
</artifact>
</target>
</configuration>
</plugin>
This setup works as long as I build the parent project. When I build one of the child modules, even if this project duplicates the reference to the target platform OR even when I build the parent with mvn install -pl org.acme.project I get the following exception:
[ERROR] Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact myGroup:org.acme.project.target:target:platform_rcp:2.3.0-SNAPSHOT -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact myGroup:org.acme.project.target:target:platform_rcp:2.3.0-SNAPSHOT
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
Even the Tycho example doesn't work for me, but brings the same error message (Could not resolve target platform specification artifact example.group:mars:target:1.0.0-SNAPSHOT).
I thought this question was similar, but my setup is exactly what is said to work in the answer.
What did I do wrong?
(The actual problem in question is that Eclipse Mars can't run integration tests, so I can only use Tycho to run them, which needs a long time when Tycho builds all modules.)
even when I build the parent with mvn install -pl org.acme.project I get the following exception:
Have you tried prepending the target platform project to the list of -pl arguments: mvn install -pl :mars,org.acme.project
I use this all the time.

Build local eclipse plugins using tycho pointing to local p2 repository

I am creating some Eclipse plugin and features that require third-party plugins and features. In order to include these dependencies into my project, I created a p2 layout repository.
Note: My p2 artifacts are not Maven project... However, I am using Maven style building. Here is the pom.xml for the p2 repository
<properties>
<tycho-version>0.18.0</tycho-version>
</properties>
<repositories>
<repository>
<id>eclipse-platform-m6</id>
<layout>p2</layout>
<url>http://download.eclipse.org/eclipse/updates/3.8</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-p2-extras-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>publish-features-and-bundles</goal>
</goals>
<configuration>
<compress>false</compress>
<artifactRepositoryLocation>/mypath/target/repository</artifactRepositoryLocation>
<metadataRepositoryLocation>/mypath/target/repository</metadataRepositoryLocation>
<sourceLocation>/mypath/src</sourceLocation>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>verify-repository</goal>
<goal>archive-repository</goal>
</goals>
<configuration>
<compress>false</compress>
<includeAllDependencies>true</includeAllDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-publisher-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<publishArtifacts>true</publishArtifacts>
</configuration>
</plugin>
<plugin><!-- enable the Tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
The above builds successfully, and creates (and verifies) a p2 repository. I get following structure in my target/ directory of the project
- Project
..
..
- target
- p2agent
- org.eclipse.equinox.p2.core
- org.eclipse.equinox.p2.engine
- repository
- features
- plugins
artifacts.xml
content.xml
<projectname>-<version>.zip <!-- This contains same things as repository directory here -->
Now, I use Tycho for building my plugins and features and refer the p2 repository I created above. I have following project structure for my plugins and features
- bundle.parent
- bundle.mainplugin
- bundle.mainplugin.test.fragment
- bundle.mainplugin.feature
Here is my bundle.parent pom.xml
<repositories>
<repository>
<id>eclipse-platform-m6</id>
<layout>p2</layout>
<url>http://download.eclipse.org/eclipse/updates/3.8</url>
</repository>
<repository>
<id>third-party-eclipse-plugins</id>
<layout>p2</layout>
<url>file:///.../target/repository</url>
</repository>
</repositories>
<modules>
<module>../bundle.mainplugin</module>
<module>../bundle.mainplugin.test.fragment</module>
<module>../bundle.mainplugin.feature</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
Finally, I run goals mvn clean install on the parent pom.xml. Unfortunately, mvn-compile throws compilation issues when classes in my plugin extend some of the classes in plugins. (The classes are also required at run-time). Here is the error:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.18.0:compile (default-compile
) on project <Project Name>: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: copied.org.apache.maven.plugin.CompilationFailureException: Compilation failure
at copied.org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:442)
at org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo.execute(AbstractOsgiCompilerMojo.java:239)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
My Question:
From the compiler errors, I believe Tycho is somehow not making these third-party artifacts available to my classes for which there is a compiler error. Is there a way to determine if my plugin classes exist in the Tycho classpath?
UPDATE
Checked availability of third-party bundles that I want to be available in Tycho reactor from this location
java -jar /home/.../eclipse-3.8.2/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -debug -consolelog -application org.eclipse.equinox.p2.director -repository file:///home/../target/repository -list
All third-party bundles showed up successfully.
Sebastian Zarnekow's answer gave me a hint.
Error while building an xtext project with ant: Generation of the Grammar classes fails
As you can infer from the error message, maven fails to create language models from injection. The reason is explained in the link above:
Xtext uses the platform:/resource URI scheme of EMF.
The solution is you need to give EMFGenerator a new declaration of where the model directory should be. In **.mwe2 file, replace the following code
fragment = ecore.EMFGeneratorFragment auto-inject {}
with
fragment = ecore.EMFGeneratorFragment auto-inject {
javaModelDirectory = "/${projectName}/src-gen"
}
should do the trick.
for anyone who also runs into this problem, you can also try using:
${project.basedir}
So, say you have the following directories:
- projects:
- main-project
- local-repository
In the parent pom (i.e.: main-project/pom.xml) reference the local-repository, using a relative path, in the following way:
<url>file:${project.basedir}/target/repository</url>
Just replace :
<url>file:///.../target/repository</url>
by :
<url>file:<projectname>/deploy/target/repository</url>
(if your parent pom.xml is your root folder)

Maven/TestNG reports "Failures: 0" but then "There are test failures.", what's wrong?

I'm using Maven 2.2.1 r801777, Surefire 2.7.1, TestNG 5.14.6, Java 1.6.0_11 on Win XP.
I have only one test class with one empty test method and in my pom I have just added TestNG dependency. When I execute mvn test it prints out:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.301 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to [...]\target\surefire-reports for the individual test results.
There is no error in test reports and with -e switch:
[INFO] Trace
org.apache.maven.BuildFailureException: There are test failures.
Please refer to [...]\target\surefire-reports for the individual test results.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.
Please refer to [...]\target\surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:575)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Any idea?
EDIT
My pom:
<?xml version="1.0" encoding="UTF-8"?>
<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.sample</groupId>
<artifactId>sample</artifactId>
<name>sample</name>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<description />
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.14.6</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The only class that I have:
import org.testng.Assert;
import org.testng.annotations.Test;
#Test
public class MyTest {
#Test
public void test() {
Assert.assertEquals("a", "a");
}
}
Just created simple example project with your pom file (Fixed some parts) and put it on github ...tested with Maven 2.2.1 and Maven 3.0.2 works perfect. The cause of the problem must be somewhere else...
Please specify the surefire plugin version (2.4.1 if you face the same issue) as follows and also specify the forkmode and useManifestOnlyJar values
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<forkMode>none</forkMode><!-- 'none' is so we can debug -->
<argLine>-enableassertions</argLine>
<!--
<useManifestOnlyJar>false</useManifestOnlyJar>
<useSystemClassLoader>true</useSystemClassLoader>
-->
<suiteXmlFiles>
<suiteXmlFile>
${basedir}/src/main/resources/testng-none.xml
</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>