MojoExecutionException: Maven with Android - java

I'm using Android Studio with Maven 3.1.1 and in the package goal it crashes with a MojoExecutionException. I have readed lot of posts but I can't get the solution.
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:593)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:216)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.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)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\aapt.exe package -f --no-crunch -I C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\hvalls\Desktop\my-app\AndroidManifest.xml -S C:\Users\hvalls\Desktop\my-app\res -A C:\Users\hvalls\Desktop\my-app\target\generated-sources\combined-assets\assets -m -J C:\Users\hvalls\Desktop\my-app\target\generated-sources\r --output-text-symbols C:\Users\hvalls\Desktop\my-app\target --auto-add-overlay", Result = -1073741819
at com.jayway.maven.plugins.android.CommandExecutor$Factory$DefaultCommandExecutor.executeCommand(CommandExecutor.java:246)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:589)
... 28 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.665s
[INFO] Finished at: Tue Mar 25 22:32:34 CET 2014
[INFO] Final Memory: 19M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project my-app: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\aapt.exe package -f --no-crunch -I C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\hvalls\Desktop\my-app\AndroidManifest.xml -S C:\Users\hvalls\Desktop\my-app\res -A C:\Users\hvalls\Desktop\my-app\target\generated-sources\combined-assets\assets -m -J C:\Users\hvalls\Desktop\my-app\target\generated-sources\r --output-text-symbols C:\Users\hvalls\Desktop\my-app\target --auto-add-overlay", Result = -1073741819 -> [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/MojoExecutionException
Process finished with exit code 1
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.android.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>my-app</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4
</platform.version>
<android.plugin.version>3.8.2</android.plugin.version>
</properties>
<dependencies>
<!--Android Annotations-->
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations-api</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>2.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<configuration>
<sdk>
<platform>19</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>

This issue was a little tricky, but can be solved!
First, when you get an error message like the one you got, you should try to run the command which Maven said it failed to run, because after maven downloads dependencies and builds code etc.. Maven it self runs the initial command to make your apk. At your case it is:
C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\aapt.exe package -f --no-crunch -I C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\hvalls\Desktop\my-app\AndroidManifest.xml -S C:\Users\hvalls\Desktop\my-app\res -A C:\Users\hvalls\Desktop\my-app\target\generated-sources\combined-assets\assets -m -J C:\Users\hvalls\Desktop\my-app\target\generated-sources\r --output-text-symbols C:\Users\hvalls\Desktop\my-app\target --auto-add-overlay
So when you run this it will give you the real error output of the dx.bat tool. Just fix the errors that you see at output and rerun the mvn.
In my case I got this error because one of the image under my res folder is not a png file although the extension is png. After I fixed the file type it worked.

I had the same error and it costed me 2.5 working days to figure out the problem.
The problem actually is too long pathes on your file system! yes, too long file path!
I moved the project from:
C:\work\workspaces\intelliJ\dory3
to
C:\work\n\dory
and it instantly worked. No errors while building, no problems in IntelliJ.

Error message does not say much, but it means that building your android apk failed. if you look at maven output above error, you might see message with actual error. in my case it was:
Extracting libs
Generating R file for Planer:AndroidApk:apk:1.0.0
C:\NetBeansProjects\Planer\AndroidApk\res\values\strings.xml:30: error: Resource entry ui.separator is already defined.
C:\NetBeansProjects\Planer\AndroidApk\res\values\strings.xml:29: Originally defined here.
Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:894)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:323)
...
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command ....
...
as you can see information about problem is typed above maven error. Mine problem, for example, was duplication of string resource- for some reason Android studio have made a duplicate. So, you do not have to run that command on your own. just look at the output.

Related

Intelij Maven : error: Source option 6 is no longer supported. Use 7 or later. Is there anymore solutions?

I'm trying to install dependendies using mvn install but I got thiss error :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.299 s
[INFO] Finished at: 2021-04-07T23:29:40+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project words-api: Compilation failure: Compilation failure:
[ERROR] error: Source option 6 is no longer supported. Use 7 or later.
[ERROR] error: Target option 6 is no longer supported. Use 7 or later.
[ERROR] -> [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/MojoFailureException
'cmd' is not recognized as an internal or external command,
operable program or batch file.
I tried to find solution on stackoverflow but for now I still get same error
What I've tried :
Changing level language
2.Adding properties to pom.xml file
Other solution that I've found involves other type of IDE
Here is my pom.xml file:
<?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>groupId</groupId>
<artifactId>untitled1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm new to Maven and if you know any solutions tha I haven't tried please comment down below. I will be thankfull for your answers
Edit: I'm using apache.maven.3.8.1
Install Java 1.8 (JDK) and configure JAVA_HOME environment variable to point to the installation home of this Java version. You may need to logout/login or reboot for the environment variable change to have effect.
Maven will use it for compilation and will be able to target 1.6 version.
Java 11+ versions no longer support 1.6 target.
In IntelliJ IDEA it can be controlled here:
Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for importer
Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Runner | JRE
A quick solution is to use the maven docker image with required jdk
maven
create the docker volume
docker volume create --name maven-repo
run the maven docker from the root folder of the app
docker run --rm -it \
-v maven-repo:/root/.m2 \
-v "$(pwd)":/usr/src/mymaven \
-w /usr/src/mymaven \
maven:3.2.5-jdk-8 \
mvn clean install

Maven build and maven-failsafe-plugin - The forked VM terminated without properly saying goodbye

I use Docker and https://github.com/fabric8io/docker-maven-plugin for my integration tests.
On my Windows 10 (after updating to Windows 10 1709) machine I faced the following error with my Maven 3.5.0 build:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (default) on project api: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projects\example\api\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "c:\Java\jdk1.8.0_152\jre\bin\java -jar C:\Users\ALEXAN~1\AppData\Local\Temp\surefire1232565117555778729\surefirebooter3745527118196863348.jar C:\Users\Alexander\AppData\Local\Temp\surefire1232565117555778729 2017-10-19T16-45-23_780-jvmRun1 surefire4633356271541422594tmp surefire_169922891955689988tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] com.example.domain.api.flag.FlagControllerIT
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Right now I have no idea what can be wrong, I don't see any failures with my tests.
What can be a reason of this issue and how to solve it?
UPDATED
My project have the following configuration:
parent pom.xml:
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF-8 -Xms1024m -Xmx1024m -XX:PermSize=1024m -noverify</argLine>
</configuration>
</plugin>
</plugins>
</build>
sub-module pom.xml:
<profiles>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
As you can see - I added
<argLine>-Dfile.encoding=UTF-8 -Xms1024m -Xmx1G -XX:PermSize=1024m -noverify</argLine>
to the configuration of maven-surefire-plugin to my parent pom.xml but it didn't help.
This is output for Maven build with -e and -X
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:58 min
[INFO] Finished at: 2017-10-19T22:27:40+03:00
[INFO] Final Memory: 62M/1117M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (default) on project domain: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projects\example\domain\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "c:\Java\jdk1.8.0_152\jre\bin\java -jar C:\Users\ALEXAN~1\AppData\Local\Temp\surefire7778309393610397922\surefirebooter4888497370312362560.jar C:\Users\Alexander\AppData\Local\Temp\surefire7778309393610397922 2017-10-19T22-26-15_682-jvmRun1 surefire8701817832311419883tmp surefire_01518784195718073645tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] com.example.domain.DecisionCharacteristicIT
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (default) on project domain: There are test failures.
Please refer to D:\Projects\example\domain\target\failsafe-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was cmd.exe /X /C "c:\Java\jdk1.8.0_152\jre\bin\java -jar C:\Users\ALEXAN~1\AppData\Local\Temp\surefire7778309393610397922\surefirebooter4888497370312362560.jar C:\Users\Alexander\AppData\Local\Temp\surefire7778309393610397922 2017-10-19T22-26-15_682-jvmRun1 surefire8701817832311419883tmp surefire_01518784195718073645tmp"
Error occurred in starting fork, check output in log
Process Exit Code: 1
Crashed tests:
com.example.domain.DecisionCharacteristicIT
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
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)
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:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
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.MojoExecutionException: There are test failures.
Please refer to D:\Projects\example\domain\target\failsafe-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was cmd.exe /X /C "c:\Java\jdk1.8.0_152\jre\bin\java -jar C:\Users\ALEXAN~1\AppData\Local\Temp\surefire7778309393610397922\surefirebooter4888497370312362560.jar C:\Users\Alexander\AppData\Local\Temp\surefire7778309393610397922 2017-10-19T22-26-15_682-jvmRun1 surefire8701817832311419883tmp surefire_01518784195718073645tmp"
Error occurred in starting fork, check output in log
Process Exit Code: 1
Crashed tests:
com.example.domain.DecisionCharacteristicIT
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
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)
at org.apache.maven.plugin.surefire.SurefireHelper.throwException(SurefireHelper.java:235)
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:112)
at org.apache.maven.plugin.failsafe.VerifyMojo.execute(VerifyMojo.java:188)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :domain
This is the full detailed output log: https://files.fm/u/nfegb38f
Windows 10 1709 update
Right now I have thoughts that this issue can be potentially related to the Windows 10 1709 update... I use docker and https://github.com/fabric8io/docker-maven-plugin for my integrstion tests and found the following topic - https://github.com/docker/for-win/issues/1221 Something is definitely wrong with this update and virtualization...
I use the maven-surefire-plugin:2.22.1, but the forked VM still crashes.
In my case the configuration forkedProcessExitTimeoutInSeconds for the maven-surefire-plugin helps. The default value are since maven-surefire-plugin:2.20.1 30 seconds. My project gots very time consuming test and so the forked JVM chrashes. Configure the plugin in the pom with the following property solves the problem.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
</configuration>
</plugin>
I have the same problem and found three solutions which working for me:
Problem description
Problem is with maven plugin maven-surefire-plugin only in version 2.20.1 and 2.21.0. I checked and you use version 2.20.1.
Solution 1
Upgrade plugin version to 2.22.0. Add in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
Solution 2
Downgrade plugin version to 2.20. Add in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
</plugin>
Solution 3
Use plugin configuration testFailureIgnore. Add in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
I'm also have error like that, related with forkstarter on the surefire plugin
maybe you can try add this on your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-modules java.base ${argLine} -Xmx1024m -XX:MaxPermSize=256m</argLine>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
Hope, this can help you
VM can crash because of many reasons. I am highlighting here one more cause it can crash.
I was using maven-surefire-plugin version 2.22.0 with jvm config -Xmx2048m but still it was failing for me.
Cause of failure:
Accidentally I changed windows command prompt 'window buffer size' width to 2000 instead of changing the height. It causes the vm crashes in my case. When i ran the build using git bash it worked fine. So I able to figure out the issue and reverted the command prompt 'window buffer size' width to default value and it worked fine for me.
Troubleshooting step:
Use different command tool to verify this issue. like window command prompt, git bash.
I have version 2.22.2 and still get that error. I get pass this by setting the timeout for surefire. So the latest added tests added execution time to exceed the default 30 secs.
mvn test -Dsurefire.exitTimeout=40
default value for timeout is 30
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#forkedProcessExitTimeoutInSeconds
<maven.surefire.plugin.version>2.22.2</maven.surefire.plugin.version>
Edit: Actually the logging happening during the tests added up so much time to get timeout. So I changed logging levels.
Try out with Manven OPT parameter
export MAVEN_OPTS="-Xms1024m -Xmx1G -XX:PermSize=1024m -noverify"
I have the same problem following solution is working for me:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
</includes>
<properties>
<excludeTags>slow</excludeTags>
</properties>
</configuration>
</plugin>

Maven - Is `maven-archetype-simple` a valid archetype?

Usually, I create maven jar project with archetype maven-archetype-quickstart, it works well.
But I want to create Maven project with no sample App.java class, thus I tried maven-archetype-simple archetype, and get error.
Maven command:
mvn archetype:generate -DgroupId=eric -DartifactId=hello -Dversion=0.1 -DarchetypeArtifactId=maven-archetype-simple -DinteractiveMode=false -X -DarchetypeCatalog=local
Error tip:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-archetype-plugin:2.4:generate
(default-cli) on project standalone-pom: The defined artifact is not
an archetype -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal
org.apache.maven.plugins:maven-archetype-plugin:2.4:generate
(default-cli) on project standalone-pom: The defined artifact is not
an archetype at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at
org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 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:497) 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.MojoFailureException: The defined
artifact is not an archetype at
org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:205)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more Caused by:
org.apache.maven.archetype.exception.ArchetypeGenerationConfigurationFailure:
The defined artifact is not an archetype at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator.configureArchetype(DefaultArchetypeGenerationConfigurator.java:150)
at
org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:189)
... 22 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
The questions are:
Is maven-archetype-simple a valid archetype?
In the official doc of maven, it says maven-archetype-simple is a archetype, refer: https://maven.apache.org/guides/introduction/introduction-to-archetypes.html , but it won't work in my test, so get confused.
How to create Maven project without the generated code App.java?
The artifact maven-archetype-simple does exist on Maven Central, but it isn't a valid archetype since it doesn't containt the right metadata files. A valid archetype must have in its JAR file:
either a META-INF/maven/archetype-metadata.xml (this is the new format);
or a META-INF/maven/archetype.xml or even a META-INF/archetype.xml (this is the old format).
And that specific artifact, as it is present on Central, doesn't have those files. As such, it isn't considered a valid archetype for the plugin. Those files store the required parameters for the archetype, their possible default values, the files that it should use, etc. so they really are required.
I'm not sure there exists an archetype that would generate just a lone pom.xml with the given Maven coordinates. This is effectively what using the maven-archetype-quickstart, without generating the App.java and AppTest.java would do. Keep in mind that an archetype is really intended at creating a project from a pre-defined template, like a sample Java EE application, or a sample Maven project; all of those would require more set-up than just writing a POM file.
If you really, really, do not want those files, you can either
Create your own archetype
Create a new Maven project, for example my-simple-archetype, with the following directory structure:
pom.xml
src
\---main
\---resources
+---archetype-resources
| pom.xml
|
\---META-INF
\---maven
archetype-metadata.xml
Content of pom.xml at the root:
<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>eric</groupId>
<artifactId>my-simple-archetype</artifactId>
<version>0.1</version>
<packaging>maven-archetype</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>2.4</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Content of the src/main/resources/archetype-resources/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</project>
And finally, content of the src/main/resources/META-INF/maven/archetype-metadata.xml:
<archetype>
<id>my-simple-archetype</id>
</archetype>
Now you can build this project and install it:
cd my-simple-archetype
mvn clean install
This will update your local catalog so that this new archetype is available. You can finally use it! In a new directory, do
mvn archetype:generate -DgroupId=eric -DartifactId=hello -Dversion=0.1 -DarchetypeArtifactId=my-simple-archetype -DarchetypeGroupId=eric -DinteractiveMode=false
And you will have as result your wanted project... which consists of the lone pom.xml. So, of course, you can now customize this archetype of yours.
Remove the files
Or you decide that it is not worth the effort, and it is a lot simpler to remove the files after their creation:
mvn archetype:generate -DgroupId=eric -DartifactId=hello -Dversion=0.1 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
rmdir /S /Q hello\src
Or rm -rf hello/src if you're on a Linux machine.
About maven-archetype-simple, even if it would be valid (which isn't the case), it's a little outdated (2006). I suggest you use something more up to date so that plugins and java versions aren't too old.
java8-quickstart-archetype would fit the bill:
mvn archetype:generate -DgroupId=eric -DartifactId=hello \
-Dversion=0.1 -DarchetypeArtifactId=java8-quickstart-archetype \
-DarchetypeGroupId=pl.org.miki -DinteractiveMode=false
This archetype sources can be found here: github.com/mikolak-net/java8-quickstart-archetype.
It is a valid maven archetype, see https://mvnrepository.com/search?q=maven-archetype-simple

maven tomcat7 deployment Error 403

Hello
I know kind of this question was put into here several times already and I read many of the answers, unfortunately, nothing worked or me so far.
What am I using:
Windows7
Tomcat 7
Maven - plugin 'tomcat7-maven-plugin'
Application has java in backend, frontend javascript
What is working so far:
I can compile, build, ..., deploy the war manually and the webapp runs fine in localhost.
What I try now:
Build and automatically deploy the app with Maven.
Via the tomcat-plugin I planned to deploy the generated war file automatically. I hope this thought is not already wrong; if so, please let me know.
Ok let me list what I have set in the different files and what I have executed.
Settings.xml of maven:
<server>
<id>TomcatServer</id>
<username>testuser</username>
<password>testpw</password>
</server>
tomcat-users.xml:
I decided to take all, so that no role can be missed and lead to a problem. I also tried with just using "manager-gui" and with "manager-gui and admin".
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="testuser" password="passwd" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
pom.xml:
...
<modelVersion>4.0.0</modelVersion>
<groupId>com.mr</groupId>
<artifactId>myWebapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>my Web App</name>
<url>http://maven.apache.org</url>
<dependencies>
...
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://LuklHost:port/manager</url>
<server>TomcatServer</server>
<username>testuser</username>
<password>passwd</password>
<path>/myWebapp</path>
</configuration>
</plugin>
</plugins>
Step to deploy:
In powershell (opened with admin-rights)
mvn tomcat:deploy
leads to following 403 error-message:
(localhost needed to be "deleted")
[INFO] Deploying war to http://localhost:8080/TripleDictionary
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.821s
[INFO] Finished at: Sat Apr 12 13:59:37 CEST 2014
[INFO] Final Memory: 18M/223M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project TripleDictionary: Ca
nnot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2FTri
pleDictionary&war= -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:depl
oy (default-cli) on project TripleDictionary: Cannot invoke Tomcat manager
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
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.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.MojoExecutionException: Cannot invoke Tomcat manager
at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2
FTripleDictionary&war=
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604)
at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
... 22 more
[ERROR]
[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/MojoExecutionException
Question:
Why do I get this error? And of course how can I fix it?
Actually I really cannot put it exact, because I think I kind of checked everything, even what folder has which rights.
Hope for ideas and help.
Thanks in advance,
Meru
I want to add thee solution as an 'answer', due to I searched for it hell of long and maybe somebody else does not need to spend that much time on it then. As I already have written the comment 'text' is needed to be appended to the url inside the plugins-part of the plugins in the pom.xml.
Let me share what I got now:
maven>conf>settings.xml
<server>
<id>TomcatServer</id>
<username>testuser</username>
<password>testpw</password>
</server>
tomcat>conf>tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-gui"/>
<user username="testuser" password="passwd" roles="admin-gui, manager-gui,manager-script"/>
But the most important I think was changing the URL, which also is the answer to my question.
pom.xml:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<username>testuser</username>
<password>passwd</password>
<path>/myWebApp</path>
</configuration>
</plugin>
command in powershell
mvn tomcat7:deploy

JBehave Stories will not run as Embeddables

I have been attempting to run concurrent, multi-threaded stories using JBehave. They run correctly when using the embedder, but when running them as embeddables, they don't execute. When I change the source directories or the scope, I get a nullpointerException and when I comment them out, it builds successfully but does not find the class "My-ProgramStories.java." When I execute them using Maven with "mvn clean verify" this is what is returning (sorry for the ugly formatting):
[INFO] --- jbehave-maven-plugin:3.7.5:run-stories-as-embeddables (embeddable-stories) # program-test> ---
[INFO] Running stories as embeddables using embedder
Embedder[storyMapper=StoryMapper,storyRunner=StoryRunner,
embedderMonitor=MavenEmbedderMonitor,classLoader=EmbedderClassLoader[urls=[/Users//Documents/Repositories///target/test-classes/,
/Users//Documents/Repositories///target/classes,
groovy-all-1.8.4.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:3.7.5,
parent: sun.misc.Launcher$AppClassLoader#1729854]],embedderControls=
UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories
true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=false,
verboseFiltering=false,storyTimeoutInSecs=400,threads=4]],
embedderFailureStrategy=org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed#127c1
ee,configuration=org.jbehave.core.configuration.MostUsefulConfiguration#10c56cbd,candidateSte
s=[],stepsFactory=,metaFilters=[groovy: story_path ==~ /.*.story/],systemProperties
{},executorService=,executorServiceCreated=false,storyManager=]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:04.710s
[INFO] Finished at: Mon Jul 29 09:55:43 CDT 2013
[INFO] Final Memory: 60M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.7.5:run-stories-as
embeddables (embeddable-stories) on project : Failed to run stories as
embeddables: NullPointerException -> [Help 1]
This is how I have the JBehave Maven Plugin configured in the POM:
<properties>
<embeddables>**/My-ProgramStories.java</embeddables>
<ignore.failre.in.stories>true</ignore.failre.in.stories>
<meta.filter>groovy: story_path ==~ /.*.story/</meta.filter>
<threads>4</threads>
<story.timeout.in.secs>400</story.timeout.in.secs>
</properties>
...
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<executions>
<execution>
<id>embeddable-stories</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>${embeddables}</include>
</includes>
<excludes>
<exclude>${exclude}</exclude>
</excludes>
<scope>test</scope>
<sourceDirectory>src/test/java</sourceDirectory>
<testSourceDirectory>src/test/resources</testSourceDirectory>
<skip>${skip}</skip>
<batch>false</batch>
<threads>${threads}</threads>
<storyTimeoutInSecs>${story.timeout.in.secs}</storyTimeoutInSecs>
<generateViewAfterStories>true</generateViewAfterStories>
<ignoreFailureInStories>
${ignore.failre.in.stories}
</ignoreFailureInStories>
<ignoreFailureInView>true</ignoreFailureInView>
<metaFilters>
<metaFilter>${meta.filter}</metaFilter>
</metaFilters>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.4</version>
</dependency>
</dependencies>
</plugin>
The structure of my story and test classes along with my story files as viewed through Eclipse is the following:
my-program-test
-->src/test/java
---->package1
------>My-ProgramSteps.java
------>My-ProgramStories.java
-->src/test/resources
---->package1
------>Story Files
Here is the stacktrace of the error:
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.7.5:run-stories-as-embeddables (embeddable-stories) on project my-program: Failed to run stories as embeddables: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:3.7.5:run-stories-as-embeddables (embeddable-stories) on project my-program-test: Failed to run stories as embeddables
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: org.apache.maven.plugin.MojoFailureException: Failed to run stories as embeddables
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:20)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.NullPointerException
at org.codehaus.plexus.util.AbstractScanner.normalizePattern(AbstractScanner.java:327)
at org.codehaus.plexus.util.AbstractScanner.setExcludes(AbstractScanner.java:314)
at org.jbehave.core.io.StoryFinder.scanDirectory(StoryFinder.java:218)
at org.jbehave.core.io.StoryFinder.scan(StoryFinder.java:205)
at org.jbehave.core.io.StoryFinder.findClassNames(StoryFinder.java:61)
at org.jbehave.mojo.AbstractEmbedderMojo.classNames(AbstractEmbedderMojo.java:302)
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18)
... 21 more
Based on this
Caused by: java.lang.NullPointerException at
org.codehaus.plexus.util.AbstractScanner.normalizePattern(AbstractScanner.java:327) at
org.codehaus.plexus.util.AbstractScanner.setExcludes(AbstractScanner.java:314) at
Looks like your exclusion pattern configuration is broken. It would look like this:
<exclude>${exclude}</exclude>
is not defined in your properties. You could use effective-pom to confirm if all properties are properly expanded.

Categories

Resources