Looks like something is wrong in cucumber-jvm parallel and surefire plugin configuration - cucumber-jvm

Environment - Cucumber V. 4.2.3 | Selenium V.3.8.1 | JUnit V.4.12 | cucumber-jvm- parallel-plugin V.1.2.1 | maven-surefire-plugin V.2.19.1 | maven-compiler- plugin v.3.3
While executing cucumber-jvm parallel & maven surefire plugin, I am facing below error
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/photon-workspace/TheDayAfterTomorrow/target/generated-test-
sources/Parallel03IT.java:[9,14] cannot find symbol
symbol: method format()
location: #interface cucumber.api.CucumberOptions
[ERROR] /D:/photon-workspace/TheDayAfterTomorrow/target/generated-test-
sources/Parallel01IT.java:[9,14] cannot find symbol
symbol: method format()
location: #interface cucumber.api.CucumberOptions
[ERROR] /D:/photon-workspace/TheDayAfterTomorrow/target/generated-test-
sources/Parallel02IT.java:[9,14] cannot find symbol
symbol: method format()
location: #interface cucumber.api.CucumberOptions
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------
------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------
------
[INFO] Total time: 6.169 s
[INFO] Finished at: 2019-02-17T13:43:48+05:30
[INFO] ------------------------------------------------------------------
------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:3.3:testCompile (default-testCompile) on project
TheDayAfterTomorrow: Compilation failure: Compilation failure:`
[ERROR] /D:/photon-workspace/TheDayAfterTomorrow/target/generated-test-
sources/Parallel03IT.java:[9,14] cannot find symbol
[ERROR] symbol: method format()
[ERROR] location: #interface cucumber.api.CucumberOptions
[ERROR] /D:/photon-workspace/TheDayAfterTomorrow/target/generated-test-
sources/Parallel01IT.java:[9,14] cannot find symbol
[ERROR] symbol: method format()
[ERROR] location: #interface cucumber.api.CucumberOptions
[ERROR] /D:/photon-workspace/TheDayAfterTomorrow/target/generated-test-
sources/Parallel02IT.java:[9,14] cannot find symbol
[ERROR] symbol: method format()
[ERROR] location: #interface cucumber.api.CucumberOptions
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile) on project TheDayAfterTomorrow: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:911)
at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:153)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[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/MojoFailureException
I can understand there shall be some wrong configuration in cucumber jvm parallel plugin, probably not in maven surefire as I am getting compilation error while executing POM.XML via eclipse using command -e clean install
Cucumber JVM Parallel Plugin Configuration
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>com.jacksparrow.automation.steps_definitions.functional</glue>
<outputDirectory>${project.build.directory}/generated-test-sources</outputDirectory>
<featuresDirectory>src/test/resources/features/functional/</featuresDirectory>
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<format>json,html</format>
<tags>"#guest_plp"</tags>
</configuration>
</execution>
</executions>
</plugin>
Maven Surefire Plugin Configuration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>2</forkCount>
<reuserForks>true</reuserForks>
<!-- <parallel>all</parallel> -->
<!-- <useUnlimitedThreads>true</useUnlimitedThreads> -->
<!-- <threadCountMethods>2</threadCountMethods> -->
<includes>
<include>**/Parallel*IT.class</include>
</includes>
</configuration>
</plugin>
**Maven Compiler Plugin**
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
Not able to understand what exactly is causing this error. Please is the jvm generated runner file**
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(strict = true,
features = {"classpath:functional/CheckoutOrderPlacement.feature"},
format = {"json:target/cucumber-parallel/1.json",
"html:target/cucumber-parallel/1.html", "pretty"},
monochrome = false,
tags = {"#guest_plp"},
glue = { "com.jacksparrow.automation.steps_definitions.functional" })
public class Parallel01IT {
}

Issue was because of giving parameter as format instead of giving plugin option. As I am using Cucumber v. 4 and there it's already depreciated. So changing the format to plugin in pom.xml resolved the issue.

Remove double quotes
"#guest_plp"

Related

JUnit4Provider Does Not Work

I'm trying to get project with the packaging type eclipse-test-plugin to work (I have the ambitious goal to get it to execute tests someday, but right now there are only two classes with empty tests methods inside).
I assume the problem only exists because we use a target configuration file, so needed plug-ins (or whatever) get not loaded automatically. In the absence of an up-to-date documentation or examples I guessed that the pom.xml for such a use case should look something like that:
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>${see.below}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>0.22.0</version>
<configuration>
<providerHint>junit4</providerHint>
</configuration>
</plugin>
</plugins>
</build>
(Because without the dependency I got a ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider, and that's where the class resides.)
Now if I use the version 2.18.1 or below of the surefire-junit4, I get the following error:
An error has occurred. See the log file C:\workspaces\workspace\org.acme.project.rxp-build\org.acme.project.rxp.it\target\work\data\.metadata\.log.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test (default-test) on project org.acme.project.rxp.it: An unexpected error occured while launching the test runtime (return code 13). See log for details. -> [Help 1]
Aaand the log file in question contains:
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider
at org.apache.maven.surefire.util.ReflectionUtils.loadClass(ReflectionUtils.java:251)
at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:128)
at org.apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:235)
at org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:113)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:78)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:91)
at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:21)
If I use version 2.19 of the surefire-junit4, I get the following message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (test) on project org.acme.project.rxp.it: Execution test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: There was an error in the forked process
[ERROR] org.apache.maven.surefire.util.SurefireReflectionException: java.lang.NoSuchMethodError: org.apache.maven.surefire.providerapi.ProviderParameters.isInsideFork()Z
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:134)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.createProviderInCurrentClassloader(ForkedBooter.java:230)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:199)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] Caused by: java.lang.NoSuchMethodError: org.apache.maven.surefire.providerapi.ProviderParameters.isInsideFork()Z
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.<init>(JUnit4Provider.java:103)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[ERROR] at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:130)
I was a bit suspicious that surefire-api and surefire-junit4 had the same version, so I made sure that Maven loads the same versions for both, but there was no change in the behavior.
What's the problem here? How do I get the test plug-in to build?
Okay, it works without stupid Maven dependencies if the target platform file contains
<unit id="org.hamcrest.core" version="0.0.0"/>
<unit id="org.junit" version="0.0.0"/>
<unit id="org.eclipse.jdt.junit.runtime" version="0.0.0"/>
<unit id="org.eclipse.jdt.junit4.runtime" version="0.0.0"/>
and the Manifest.MF contains
Require-Bundle: org.eclipse.jdt.junit4.runtime,
org.junit
up-to-date documentation: https://www.eclipse.org/tycho/documentation.php
mentions working examples: http://git.eclipse.org/c/tycho/org.eclipse.tycho-demo.git/

Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor

[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
---- Debugging information ----
message : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
class : org.apache.maven.plugin.war.util.WebappStructure
required-type : org.apache.maven.plugin.war.util.WebappStructure
path : /webapp-structure
line number : 1
-------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Trace
com.thoughtworks.xstream.converters.ConversionException: Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
---- Debugging information ----
message : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
class : org.apache.maven.plugin.war.util.WebappStructure
required-type : org.apache.maven.plugin.war.util.WebappStructure
path : /webapp-structure
line number : 1
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:63)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:781)
at org.apache.maven.plugin.war.util.WebappStructureSerializer.fromXml(WebappStructureSerializer.java:73)
at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:404)
at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:375)
at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:181)
at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:143)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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: com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.newInstance(PureJavaReflectionProvider.java:59)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.instantiateNewInstance(AbstractReflectionConverter.java:257)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:124)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Sat Sep 24 17:25:45 CEST 2011
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
JDK: 1.7
Maven compiler Plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
When I run install target above error occurs, how can I resolve it?
Perhaps a version of maven war plugin is being used, which does not work with Java 7? As per this issue (which describes a similar problem), 2.1.1 version of maven war plugin should work.
Include the following in your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
I had this problem when doing a mvn install. I resolved it by doing a mvn clean first, followed by a mvn install.
Using maven 2.1.1, JDK 1.7.0.45.
It's confirmed: JDK7 with Maven 2.x will produce this error.
I am using Maven 2.2.1 and JDK7 and got this error. I changed the JDK to version 1.6 and it's working fine.
Instead of changing JDK versions and Maven versions, try this:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>2.3.2</version>
</plugin>
Confirmed, I ran into the same issue with maven 3.0.2 and jdk 1.7.0_02. After running against jdk 1.6.0_30 it compiled just fine.
I don't think the version was the problem.
I solved deleting my target folder (because it contains webapp-cache.xml) and doing Maven install again.
Apache Maven WAR Plugin 3.0.0 resolved all issues:
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
It doesn't matter if you use jdk 1.6, 1.7 or 1.8
This definitely seems to be related to incompatible plugin, library and language versions.
Two years, and two Java versions later, I had this same error while doing a sample project from an older book on Spring and Hibernate.
I was able to resolve the error by commenting out all of the version tags for the apache.maven.plugins and setting the Java version to 1.8. This let me know what was the latest and greatest version of the libraries, with the cost of some warnings from Maven about missing the version tags. If you care about the warnings, you can set the version tags to be latest version and the warnings from Maven should go away.
I executed mvn clean package and then just mvn package.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<!-- <version>2.1-beta-1</version> -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>2.1</version> -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
if your using jdk 1.6 kindly add this plugin entry to your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
I had this problem with my eclipse Kepler. As soon as I moved to 4.4 (Luna) , all gone. Must be an issue with eclipse + maven embedded
I tried both JDK 1.7 and 1.8. No difference.
For me changing plugin version could not solve problme and changing JDK version is not in my control.
However running mvn clean before mvn tomcat6:deploy solved this problem.
Make sure to have the JDK version in your Build path and the version specified in the
source tag match the same.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
**<source>1.7</source>**
<target>1.7</target>
<debug>true</debug>
</configuration>
</plugin> `
I had the build path pointing to jdk 1.7 and "1.6" in the source tag, when I corrected the version to 1.7 in source tag the issue got resolved.
Execute mnv clean and mvn package.
Try to delete all your cache. When i deleted target folder, it works fine.
(Target folder is where maven puts all compiled code)
I was getting the same error after i upgraded my java version from 8 to some 8.x, i fixed it by going to pom then 1. right click > maven > add plugin 2. type in org.apache.maven and then look for war plugin add it and save, then just clean and install. It should work.
use this plugin
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
Example pom.xml
pom.xml screenshot`
Use this below plugin to get rid of this issue ( Latest ) and refer this
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
<finalName>SampleProject</finalName>
</build>

exec-maven-plugin goal is not started during build

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>

Maven - add source dependency; but no java source files available in eclipse for GWT compile

Usually the below pom config works for me. I've been successful in the past at adding my jar file's source to my projects as a dependency?
I have two jar files defined like so:
<dependencies>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar</artifactId>
<version>4.0</version>
<type>jar</type>
<classifier>sources</classifier>
</dependency>
</dependencies>
When I open up the myJar-4.0-sources.jar file from windows explorer view, I see all the java source files in it associated packages. But when I look in my eclipse project in my maven dependencies I only see xml files and no java files for myJar-4.0-sources.jar
BTW, regardless if I run the maven build inside eclipse or outside, it complains that there is no source code for classes that should be found in myJar-4.0-sources.jar.
BTW, this is a GWT compile.
Here is the actual error message:
[INFO] [gwt:compile {execution: default}]
[INFO] auto discovered modules [com.noesis.calendar.events.CalendarEvents]
[INFO] Loading inherited module 'com.noesis.commons.Commons'
[INFO] [WARN] Non-canonical source package: ./
[INFO] Compiling module com.noesis.calendar.events.CalendarEvents
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'file:/C:/dev/pouncil_projects/calendar-events/src/main/java/com/noesis/calendar/events/shared/model/Calendar
Event.java'
[INFO] [ERROR] Line 102: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inher
it a required module?
[INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0
.1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/BaseEntityModel.java'
[INFO] [ERROR] Line 27: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inheri
t a required module?
[INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0
.1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/DomainModelException.java'
[INFO] [ERROR] Line 6: No source code is available for type com.noesis.commons.exceptions.ApplicationException; did you forget to i
nherit a required module?
[INFO] [ERROR] Line 14: No source code is available for type com.noesis.commons.Context; did you forget to inherit a required modul
e?
[INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0
.1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/PersistableBaseModel.java'
[INFO] [ERROR] Line 70: No source code is available for type com.noesis.commons.calendar.CalendarUtility; did you forget to inherit
a required module?
[INFO] [ERROR] Line 84: The method clone() is undefined for the type Object
[INFO] [ERROR] Line 91: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inheri
t a required module?
[INFO] Finding entry point classes
[INFO] [ERROR] Unable to find type 'com.noesis.calendar.events.client.CalendarEvents'
[INFO] [ERROR] Hint: Previous compiler errors may have made this type unavailable
[INFO] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not b
e adding its source path entries properly
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR`
[INFO] [ERROR] Line 102: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inher
it a required module?
Does anybody have any idea why this is the case?
GWT looks for dependency sources in the same JAR as the compiled
class files. Since the library is under your control your best
course is to include the class files and the source files in the
same JAR. To do so add a <resource> to the <build> section of
the POM (assuming standard Maven source layout):
<project>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
</project>
GWT looks for dependency sources in the same JAR as the compiled class files. Your should include the class files and the source files in the same JAR. To do so add a <resource> to the <build> section of the POM:
<project>
<build>
<resources>
<!-- include the source files in our main jar for use by GWT -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
</resource>
<!-- and continue to include our standard resources -->
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
</project>
I finally figured out my problem was. It was my .gwt.xml file. It was not referencing the GWT classes correctly. Not that I solved this, I believe the original way I wanted to reference my source library via the source jar file will work. Thanks.

Maven: properties not being substituted

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}.