Recently I'm working with test automation. The goal is to get quicker feedback so we decided to use maven-jmeter-plugin, jmeter scripts and Hudson.
I have wrote some example jmeter scripts templates and they are working fine (just a quick smoke test for accessing pages).
The problem is that script I have to complete requires 'HTTP Cookie Menager' to run correctly.
Here is dummy script I'm using at the moment trying identify what is wrong.
Test Plan
|-> Thread Group
|-> HTTP Cookie Menager
|-> Loop Controler
|-> HTTP request
I use the same configuration as in other working examples I have prepared (jmeter.properties, update.properties, system.properties - in the last file I keep values used by script like number of users, loop count, host, etc).
When I run it with mvn clean verify it returns following output:
mvn -e clean verify
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
Profile with id: 'development,hudson' has not been activated.
[INFO] ------------------------------------------------------------------------
[INFO] Building com.cybercom.test::peformance-test-mvn
[INFO] task-segment: [clean, verify]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\Hudson\data\jobs\peformance-test-mvn\workspace\trunk\target
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [jmeter:jmeter {execution: jmeter-tests}]
[INFO] Executing test: C:\Hudson\data\jobs\peformance-test-mvn\workspace\trunk\src\test\jmeter\temp.jmx
Error in NonGUIDriver java.lang.NullPointerException
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There were test errors
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: There were test errors
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:55
6)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.jav
a: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 were test errors
at org.apache.jmeter.JMeterMojo.checkForErrors(JMeterMojo.java:115)
at org.apache.jmeter.JMeterMojo.execute(JMeterMojo.java:102)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
The same script without HTTP Cookie Menager works perfectly well, but as I mentioned this is just dummy script to investigate what is wrong.
I assume that pom file might be useful as well here it is:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>peformance-test-mvn</artifactId>
<name>${groupId}::${artifactId}</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.jmeter</groupId>
<artifactId>maven-jmeter-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<reportDir>target/jmeter-reports</reportDir>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<id>nexus</id>
<url>XXXX</url>
<name>YYYY</name>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
</project>
What am I missing??
Thanks in advance
Pawel
Problem solved.
commons-logging dependency was missing in maven-jmeter-plugin-1.0.pom
Adding following lines
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
Solved problem.
Related
I have a ignite cluster setup. There is a postgres database which has a schema. I have imported that schema into ignite. All the table names have been appended with the work 'Cache'. For e.g. Account -> AccountCache
If I play around with the console, and, inspect my ImportedCluster (which is the default name for what is imported) I can see a link below the screen to see the project structure. Here I am presented with a dialog where I can see the project structure.
Using the Save and Download option (i.e. the blue button called 'Save') in the pic below, I can download that project. How do I run this project in intellij IDE?
Update:
In the intellij ide, I figured out how to setup the maven project. And from the maven projects window, I clicked on install > Run maven build, as shown in the pic.
Here is the output it gave:
"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" -Dmaven.multiModuleProjectDirectory=D:\code\java-intellij\ignite-project "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.6\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.6\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.6\lib\idea_rt.jar=53750:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.6\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.6\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.2.6 install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ImportedCluster-project 2.7.0
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-core/2.7.0/ignite-core-2.7.0.pom
[WARNING] The POM for org.apache.ignite:ignite-core:jar:2.7.0 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-spring/2.7.0/ignite-spring-2.7.0.pom
[WARNING] The POM for org.apache.ignite:ignite-spring:jar:2.7.0 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-indexing/2.7.0/ignite-indexing-2.7.0.pom
[WARNING] The POM for org.apache.ignite:ignite-indexing:jar:2.7.0 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-rest-http/2.7.0/ignite-rest-http-2.7.0.pom
[WARNING] The POM for org.apache.ignite:ignite-rest-http:jar:2.7.0 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-core/2.7.0/ignite-core-2.7.0.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-spring/2.7.0/ignite-spring-2.7.0.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-indexing/2.7.0/ignite-indexing-2.7.0.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/ignite/ignite-rest-http/2.7.0/ignite-rest-http-2.7.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.876 s
[INFO] Finished at: 2018-11-24T08:20:59+05:30
[INFO] Final Memory: 9M/85M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ImportedCluster-project: Could not resolve dependencies for project org.apache.ignite:ImportedCluster-project:jar:2.7.0: The following artifacts could not be resolved: org.apache.ignite:ignite-core:jar:2.7.0, org.apache.ignite:ignite-spring:jar:2.7.0, org.apache.ignite:ignite-indexing:jar:2.7.0, org.apache.ignite:ignite-rest-http:jar:2.7.0: Could not find artifact org.apache.ignite:ignite-core:jar:2.7.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Process finished with exit code 1
Is it that the 2.7.0 version binaries are unavailable?
Here is the current pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file was generated by Ignite Web Console (11/23/2018, 14:12) -->
<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>org.apache.ignite</groupId>
<artifactId>ImportedCluster-project</artifactId>
<version>2.7.0</version>
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-indexing</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-rest-http</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212.jre7</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
<phase>test-compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeGroupIds>org.apache.ignite</excludeGroupIds>
<outputDirectory>target/libs</outputDirectory>
<includeScope>compile</includeScope>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
What you see in the screenshot isn't really "project structure." Instead it's the configuration file for starting Ignite with that list of caches and a connection to your PostgreSQL database.
Creating a client app to connect to that Ignite cluster basically involves following the steps in the documentation. In short:
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-indexing</artifactId>
<version>${ignite.version}</version>
</dependency>
Then you can connect to the cluster using the same configuration file.
In Above pom.xml file, you have entered ignite version 2.7 which is not available on central maven repository. So used 2.6 version and try.
Below is the procedure to start Ignite Web Console.
Follow the steps for Ignite web agent setup:-
1)If you have known IP address then select Discovery:- Static and add IP address
2)Open command prompt and run the script ignite-web-agent.sh which is present in downloaded package
3)After successful connection between web-agent and Ignite you can check on web agent console's Dashboard for your Ignite cluster
Hallo,
I try to run a main method during my maven build process. Hence, I added the exec-maven-plugin and the following snippet to my pom.xml
<plugin>
<!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>compile-reports</id>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>at.xyz.dls.util.JasperReportCompiler</mainClass>
</configuration>
</execution>
</executions>
</plugin>
The main class exists and is also executed, when I call it out of the command line:
mvn exec:java -Dexec.mainClass="at.xyz.dls.util.JasperReportCompiler"
I also tried to create a empty new project to test, if an other depencency in the pom causes the problem, but had no success. In the maven settings.xml in the ~/.m2 folder, there is only the entry for an mirror, but no profiles, or anything else, which could cause a problem.
It just does not start it. When I deleted all my artifacts in my repo under org.codehouse, it did not download the exec-maven-plugin. Only when I did the command line call.
Any hints? Thanks in advance!
edit: I forgot to mention I have used "mvn clean install". so it should have passed the compile phase...
edit:
up to now, I could not solve the problem. Thanks for your answers so far! I will try to give all information once again, and hope, one of you guys, find's the fishy part. I have no idea anymore....
What I did:
Delete the folder org/codehouse/mojo in my maven proxy. just to show, when the dependencies are loaded.
show some java and maven version information
build the project with: mvn -clean install (which should pass the test phase to execute my main method)
execute the main method to show, the exec-maven-plugin is loaded only afterwards and works
As far as I understood, calling "mvn clean install" should pass the test phase (the tests are executed...), hence the exec-maven-plugin should be called, which should execute the main method. Am I right?
D:\Eclipse-3.6.1-JSF\ws\exec-test>java -version java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn -version Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200) Java version: 1.6.0_21 Java home: C:\Programme\Java\jdk1.6.0_21\jre Default locale: de_AT, platform encoding: Cp1252 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows" D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory D:\Eclipse-3.6.1-JSF\ws\exec-test\target
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\surefire-reports
T E S T S
Running at.test.ExecTestTest JUnit Test call: end of junit test.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar to D:\maven.m2\repository\at\test\exec-test\0.0.1-SNAPSHOT\exec-test-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Thu Mar 10 12:07:08 CET 2011
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------ D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn exec:java -Dexec.mainClass="at.test.ExecTest"
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'. Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.pom 6K downloaded (exec-maven-plugin-1.2.pom) Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.jar 35K downloaded (exec-maven-plugin-1.2.jar)
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java [WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] [exec:java {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Thu Mar 10 12:07:20 CET 2011
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
D:\Eclipse-3.6.1-JSF\ws\exec-test>
now again the modified 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>at.test</groupId>
<artifactId>exec-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>exec-test</finalName>
<defaultGoal>install</defaultGoal>
<pluginManagement>
<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>
<!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>compile-reports</id>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>at.test.ExecTest</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
The main class:
package at.test;
public class ExecTest {
/**
* #param args
*/
public static void main(String[] args) {
System.out.println("##################################");
}
}
And the JUnit Test Class:
package at.test;
import org.junit.Test;
import at.test.ExecTest;
public class ExecTestTest {
#Test
public void testTestTest() {
System.err.println("JUnit Test call:");
ExecTest.main(null);
System.err.println("end of junit test.");
}
}
Finally I found the problem. Was quite a stupid mistake:
In the pom.xml I used the <pluginManagement> around the <plugins> node.
Maven did not complain, but ignored all plugin configurations.
Maybe someone can use this information...
Thanks for your help!
Compile phase may not be appropriate, have you tried
<phase>test</phase>
If you set it on phase compile then you do have to tell maven that is needs to run compile when running. You don't pass any phase with your maven command. You should have mvn compile exec:java ... or higher (test, install, ...).
This is my usage of the exec maven plugin (with mvn clean package):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.xxx.LanguageGenerator</mainClass>
<arguments>
<argument>${project.build.outputDirectory}/build/PMLanguage.xls</argument>
<argument>PM${project.version}</argument>
<argument>${project.build.outputDirectory}/com/laco/projectmaster/props/resources</argument>
<argument>Created during maven build (POM Version:
${project.version})</argument>
</arguments>
</configuration>
</plugin>
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>
I tried to build a project. It failed. I made the correct changes and tried to build it again. I relieve the following error:
Embedded error: Directory simple already exists - please run from a clean directory
dan#dan-netbook:~/Documents/Maven/mavenbook-examples-1-SNAPSHOT/ch03-simple$ mvn archetype:create -DgroupId=org.sonatype.mavenbook.ch03 -DartifactId=simple -DpackageName=org.sonatype.mavenbook -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] Chapter 3 Parent Project
[INFO] Chapter 3 Simple Project Example
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Chapter 3 Parent Project
[INFO] task-segment: [archetype:create] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [archetype:create {execution: default-cli}]
[WARNING] This goal is deprecated. Please use mvn archetype:generate instead
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.sonatype.mavenbook.ch03
[INFO] Parameter: packageName, Value: org.sonatype.mavenbook
[INFO] Parameter: package, Value: org.sonatype.mavenbook
[INFO] Parameter: artifactId, Value: simple
[INFO] Parameter: basedir, Value: /home/dan/Documents/Maven/mavenbook-examples-1-SNAPSHOT/ch03-simple
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error creating from archetype
Embedded error: Directory simple already exists - please run from a clean directory
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error creating from archetype
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
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.MojoExecutionException: Error creating from archetype
at org.apache.maven.archetype.mojos.MavenArchetypeMojo.execute(MavenArchetypeMojo.java:243)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.archetype.old.ArchetypeTemplateProcessingException: Directory simple already exists - please run from a clean directory
at org.apache.maven.archetype.old.DefaultOldArchetype.createArchetype(DefaultOldArchetype.java:251)
at org.apache.maven.archetype.old.DefaultOldArchetype.createArchetype(DefaultOldArchetype.java:117)
at org.apache.maven.archetype.mojos.MavenArchetypeMojo.execute(MavenArchetypeMojo.java:227)
... 19 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Sun Dec 12 18:53:08 EST 2010
[INFO] Final Memory: 10M/26M
[INFO] ------------------------------------------------------------------------
This leads me to believe that I need to clean the directory or something. I call mvn clean but this does not fix the problem. Im sure this is a very basic question, but Im just learning. Any suggestions?
Parent:
<pre>
<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>
<artifactId>examples</artifactId>
<groupId>org.sonatype.mavenbook</groupId>
<version>1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven: The Definitive Guide Example Code</name>
<description>Example Code for Maven: The Definitive Guide</description>
<url>http://sonatype.com/book</url>
<modules>
<module>ch03-simple</module>
<module>ch04-custom</module>
<module>ch05-simple-web</module>
<module>ch06-multi</module>
<module>ch07-multi-spring</module>
<module>ch08-optimize</module>
<module>ch09-pom</module>
<module>ch10-lifecycle</module>
<module>ch11-profile</module>
<module>ch12-assembly</module>
<module>ch13-properties</module>
<module>ch15-sitegen</module>
<module>ch17-writing-plugins</module>
<module>ch18-alternate-plugins</module>
</modules>
<build>
<finalName>mavenbook-examples-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>project</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>examples</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>publish</id>
<distributionManagement>
<site>
<id>sonatype-site</id>
<name>Sonatype Book Examples</name>
<url>file:///var/www/domains/sonatype.com/www/htdocs/book/book-examples/</url>
</site>
</distributionManagement>
<properties>
<sonatype.site>file:///var/www/domains/sonatype.com/www/htdocs/</sonatype.site>
</properties>
</profile>
<profile>
<id>stage</id>
<distributionManagement>
<site>
<id>sonatype-site</id>
<name>Sonatype Book Examples</name>
<url>file:///var/www/domains/sonatype.com/www/htdocs/book-stage/book-examples/</url>
</site>
</distributionManagement>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.0.1</version>
</plugin>
</plugins>
</reporting>
<repositories>
<repository>
<id>sonatype-forge</id>
<name>Sonatype Forge</name>
<url>http://repository.sonatype.org/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>Central</id>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
</pre>
Other Pom
<pre>
<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>
<parent>
<groupId>org.sonatype.mavenbook</groupId>
<artifactId>examples</artifactId>
<version>1-SNAPSHOT</version>
</parent>
<groupId>org.sonatype.mavenbook.ch03</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<name>Chapter 3 Parent Project</name>
<url>http://sonatype.com/book</url>
<modules>
<module>simple</module>
</modules>
</project>
</pre>
Thanks
just in case anyone else hits this problem...I ran into the same issue (just now learning maven) and here's what worked for me:
if you downloaded the code, don't run the command from the sample chapter directory, e.g. /home/uruser/maven/mavenbook-examples-1-SNAPSHOT/ch03-simple
Just setup a new dir like /home/uruser/maven/myTestChapterThree and then run the following:
mvn archetype:create -DgroupId=org.sonatype.mavenbook.ch03 -DartifactId=simple -DpackageName=org.sonatype.mavenbook -e
rookie stuff to be sure, but at least three maven noobs (myself included) have hit this wall so it could be the book's advice to download the sample chapters and then run this command that might be the issue :)
In your Application, I am confused with ArtifactId since, I see you have give as "example" where as you are passing your argument as "simple". Here is the simple example for creating a new artifact.
1. Create a new project and pom.xml for the archetype artifact
An example pom.xml for an archetype artifact looks as follows:
<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>my.groupId</groupId>
<artifactId>my-archetype-id</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
All you need to specify is a groupId, artifactId and version. These three parameters will be needed later for invoking the archetype via archetype:create from the commandline.
2. Create the archetype descriptor
The archetype descriptor is a file called archetype.xml which must be located in the src/main/resources/META-INF/maven/ directory. An example of an archetype descriptor can be found in the quickstart archetype:
<archetype
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org
/plugins/maven-archetype-plugin/archetype/1.0.0
http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>quickstart</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>
The tag should be the same as the artifactId in the archetype pom.xml.
An optional true tag makes it possible to run the archetype:create even on existing projects.
The , , , and tags represent the different sections of the project:
<sources> = src/main/java
<resources> = src/main/resources
<testSources> = src/test/java
<testResources> = src/test/resources
<siteResources> = src/site
<sources> and <testSources> can contain <source>
elements that specify a source file.
and can contain elements that specify a resource file.
Place other resources such as the ones in the src/main/webapp directory inside the tag.
At this point one can only specify individual files to be created but not empty directories.
Thus the quickstart archetype shown above defines the following directory structure:
archetype
|-- pom.xml
`-- src
`-- main
`-- resources
|-- META-INF
| `-- maven
| `--archetype.xml
`-- archetype-resources
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- App.java
`-- test
`-- java
`-- AppTest.java
3. Create the prototype files and the prototype pom.xml
The next component of the archetype to be created is the prototype pom.xml. Any pom.xml will do, just don't forget to the set artifactId and groupId as variables ( ${artifactId} / ${groupId} ). Both variables will be initialized from the commandline when calling archetype:create.
An example for a prototype pom.xml is:
<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>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
<name>A custom project</name>
<url>http://www.myorganization.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
4. Install the archetype and run the archetype plugin
Now you are ready to install the archetype:
mvn install
Now that you have created an archetype, you can try it on your local system by using the following command. In this command, you need to specify the full information about the archetype you want to use (its groupId, its artifactId, its version) and the information about the new project you want to create (artifactId and groupId). Don't forget to include the version of your archetype (if you don't include the version, you archetype creation may fail with a message that version:RELEASE was not found)
mvn archetype:create \
-DarchetypeGroupId=<archetype-groupId> \
-DarchetypeArtifactId=<archetype-artifactId> \
-DarchetypeVersion=<archetype-version> \
-DgroupId=<my.groupid> \
-DartifactId=<my-artifactId>
Once you are happy with the state of your archetype, you can deploy (or submit it to ibiblio) it as any other artifact and the archetype will then be available to any user of Maven.
Alternative way to start creating your Archetype
Instead of manually creating the directory structure needed for an archetype, simply use
mvn archetype:create
-DgroupId=[your project's group id]
-DartifactId=[your project's artifact id]
-DarchetypeArtifactId=maven-archetype-archetype
Afterwhich, you can now customize the contents of the archetype-resources directory, and archetype.xml, then, proceed to Step#4 (Install the archetype and run the archetype plugin).
I'm using a maven plugin for install4j in my project, located here. That plugin lets you pass variables to install4j using the <compilerVariables> section. Here's the relevant section of my pom:
<plugin>
<groupId>com.google.code.maven-install4j</groupId>
<artifactId>maven-install4j-plugin</artifactId>
<version>0.1.1</version>
<configuration>
<executable>${devenv.install4jc}</executable>
<configFile>${basedir}/newinstaller/ehd.install4j</configFile>
<releaseId>${project.version}</releaseId>
<attach>false</attach>
<skipOnMissingExecutable>false</skipOnMissingExecutable>
<compilerVariables>
<property>
<name>m2_home</name>
<value>${settings.localRepository}</value>
</property>
</compilerVariables>
</configuration>
</plugin>
The problem is that ${settings.localRepository} is not being substituted with the actual directory when I run the plugin. Here's the command line script that install4j is generating:
[INFO] Running the following command for install4j compile: /bin/sh -c /home/zach/install4j/bin/install4jc --release=9.1-SNAPSHOT --destination="/home/zach/projects/java/ehdtrunk/target/install4j" -D m2_home=${settings.localRepository} /home/zach/projects/java/ehdtrunk/newinstaller/ehd.install4j
Is this the fault of the plugin? If so, what needs to change to allow the substitution to happen?
The following POM just works for me (with Maven 2.2.1):
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>Q2828732</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<tasks>
<echo>${settings.localRepository}</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And running mvn process-ressources produces the following output:
$ mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Q2828732
[INFO] task-segment: [validate]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
[echo] /home/pascal/.m2/repository
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu May 13 19:28:38 CEST 2010
[INFO] Final Memory: 3M/54M
[INFO] ------------------------------------------------------------------------
Does the above work for you? Are you using M2Eclipse? Could it be related to MNGECLIPSE-299?
The plugin in question accepts a parameter which is a Properties instance. For whatever reason, expressions used to configure Properties instances are not automatically evaluated. I had to change the plugin to use a org.apache.maven.plugin.PluginParameterExpressionEvaluator to evaluate ${settings.localRepository}.