I am trying to run a simple Rest HelloWorld program as described in https://spring.io/guides/gs/rest-service/. I have downloaded Spring and Maven and added the MAVEN_HOME and M3_HOME environment variables. I have run the mvn -v command successfully in Windows command prompt. I browsed to the initial directory where the pom.xml is located. Then I run mvn spring-root:run but I get the following error:
No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\user.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
I have already searched for this error message on the internet but the suggestions are not solving my problem. Am I forgetting something related to any installation? Any idea or suggestion is highly appreciated.
Oh, I realized now I had same issue in the past...
To address
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) on project gs-rest-service: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed: Unable to find main class -> [Help 1]
You have to create Application class (something annotated with #SpringBootApplication)
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
or skip tests mvn clean install -DskipTests.
For mvnw spring-boot:run I'm getting ConnectException right now...
Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
Exception in thread "main" java.net.ConnectException: Connection refused: connect
but it is very likely issue on my side...
I know there is a similar question to this (to question: Neo4j Spatial: can't run spatial), however that question seems to be solved when installing dependencies. I think that is not the solution to my case.
After installing Neo4j and installing maven
$ brew install neo4j
$ brew install maven
making a directory called spatial and cloning neo4j-spatial to this folder.
$ git clone https://github.com/neo4j-contrib/spatial.git
Then i tried to maven install this git clone.
/spatial$ mvn install
After a lot of test it returns a "Build failure"
Results :
Failed tests:
ProgressLoggingListenerTest.testProgressLoggingListnerWithAllLogs:38->testProgressLoggingListenerWithSpecifiedWaits:62
Argument(s) are different! Wanted:
forwardingPrintStream.println(
"100.00 (10/10) - Completed test"
);
-> at org.neo4j.gis.spatial.ProgressLoggingListenerTest.testProgressLoggingListenerWithSpecifiedWaits(ProgressLoggingListenerTest.java:62)
Actual invocation has different arguments:
forwardingPrintStream.println(
"10,00 (1/10) - Running test"
);
-> at org.neo4j.gis.spatial.rtree.ProgressLoggingListener.lambda$new$1(ProgressLoggingListener.java:45)
ProgressLoggingListenerTest.testProgressLoggingListnerWithOnlyStartAndEnd:46->testProgressLoggingListenerWithSpecifiedWaits:62
Argument(s) are different! Wanted:
forwardingPrintStream.println(
"100.00 (10/10) - Completed test"
);
-> at org.neo4j.gis.spatial.ProgressLoggingListenerTest.testProgressLoggingListenerWithSpecifiedWaits(ProgressLoggingListenerTest.java:62)
Actual invocation has different arguments:
forwardingPrintStream.println(
"10,00 (1/10) - Running test"
);
-> at org.neo4j.gis.spatial.rtree.ProgressLoggingListener.lambda$new$1(ProgressLoggingListener.java:45)
Tests run: 146, Failures: 2, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10:34 min
[INFO] Finished at: 2016-09-23T15:55:35+02:00
[INFO] Final Memory: 44M/558M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project neo4j-spatial: There are test failures.
[ERROR]
[ERROR] Please refer to /Volumes/Macintosh HD/Users/Tom/spatial/target/surefire-reports for the individual test results.
[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
In my queeste to solve this "Build failure" I discovered that most maven install errors are due to dependencies. However these error messages do not indicate any missing dependencies?
I tried using mvn verify however this just seems to try to build the plugin again returning the same Build failure.
/spatial$ mvn verify
Two questions;
- Am I missing dependencies or is the problem in something else?
- If I am missing dependencies, what are they and how to install them?
Thanks in advance!
The tests depend on the locale of the build environment as it checks the result of number formatting with decimal number, expecting a point as the decimal separator:
"100.00 (10/10) - Completed test"
Your locale uses the comma as the decimal separator, based on the actual value reported:
"10,00 (1/10) - Running test"
You have 2 options:
Build the project without running the tests:
mvn install -Dmaven.test.skip
Change the locale for the build:
LANG=C mvn install
or
LANG=en_US mvn install
I'm working on datastax cassandra java driver project using Maven. I've tried to build it successfully in local machine with maven and Eclipse.
However, when I deployed the project in Amazon AWS. Every time, I ran the exec:java -Dexec.mainClass=”com.example.cassandra.App”, which is a simple Hello World java file. However, I got an error:
[ec2-user#ip-172-31-18-93 simple-client]$ mvn exec:exec
-Dexec.mainClass=”com.example.cassandra.App”
Error:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (default-cli) on project simple-client: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec are missing or invalid -> [Help 1]
However, sometime when i went into the target/classes and run java com.example.cassandra.App, it can show hello world! successfully. But when I add new java file like SimpleClient.java and compile it and run, it shows the error above.
I got the following error while running a Jenkins job
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project mosm-ui: Error unpacking file [/var/lib/jenkins/.m2/repository/com/cisco/xmp/wap/xmpweb/2.0.5/xmpweb-2.0.5.war]to [/var/lib/jenkins/jobs/MOS_2.3/workspace/target/war/work/com.cisco.xmp.wap/xmpweb]: chmod exit code was: 127 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project mosm-ui: Error unpacking file [/var/lib/jenkins/.m2/repository/com/cisco/xmp/wap/xmpweb/2.0.5/xmpweb-2.0.5.war]to [/var/lib/jenkins/jobs/MOS_2.3/workspace/target/war/work/com.cisco.xmp.wap/xmpweb]
Caused by: org.apache.maven.plugin.MojoExecutionException: Error unpacking file [/var/lib/jenkins/.m2/repository/com/cisco/xmp/wap/xmpweb/2.0.5/xmpweb-2.0.5.war]to [/var/lib/jenkins/jobs/MOS_2.3/workspace/target/war/work/com.cisco.xmp.wap/xmpweb]
The size of the xmpweb-2.0.5.war file is 209MB.
JDK - 1.7.0_55 , Maven version - 3.2.1.
OS - RHEL 6.4
Appreciate your help in advance.
You might not be passing your PATH variable correctly. Look for something that looks like :PATH and make it :$PATH
see this similar issue here and stop thinking of it as a maven failure, but rather a bad call to chmod.
I am working on a rather complex java project with many dependencies and many unit tests.
I am using java 1.6.0_65 on mac (mavericks) with maven 3.0.5 with maven-surefire-plugin:2.16 running in several forks.
My problem is that running this setup with several forks causes a fork to exit with:
"The forked VM terminated without saying properly goodbye. VM crash or
System.exit called ?"
running this with only one fork does not produce the problem (and everything passes)
There is some information out there about this problem including this StackOverflow question and this surefire bug (which seems to be solved by now)
I am aware that the "Answer" to this situation is to find what in my code calls System.exit() - Nothing i could find.
Or what causes my JVM to crash - there are no hs_pid crash reports.
My Question is what what kind of strategy can i use to find a locate this cause?
To clarify, I am not interested in the answer noted above, but a way to find where it is originating from. (Or even better a different answer altogether to what might be causing this )
my Surefire configuration is: (but i did try other combinations)
<parallel>classes</parallel>
<threadCount>1</threadCount>
<forkCount>1C</forkCount>
<reuseForks>false</reuseForks>
<useSystemClassLoader>false</useSystemClassLoader>
<useManifestOnlyJar>true</useManifestOnlyJar>
<useFile>true</useFile>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
Update #1
adding the relevant out put after running the maven goal with --debug (-X)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project event-logger: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project event-logger: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
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)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.MojoFailureException: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
at org.apache.maven.plugin.surefire.SurefirePlugin.assertNoException(SurefirePlugin.java:198)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:188)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:852)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:720)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 25 more
Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:316)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:169)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:958)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:822)
... 28 more
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:300)
... 31 more
Caused by: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:485)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:352)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.access$300(ForkStarter.java:85)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter$2.call(ForkStarter.java:288)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter$2.call(ForkStarter.java:283)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
[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
Steps:
(1) Run mvn with the -e and -X options to get more debug information.
(2) Look for "Error" in the output. In my case, when I ran the mvn command, part of the output included:
[ERROR] Command wascmd.exe /X /C "C:\dev\dev-tools\.....
(3) Execute the problematic command directly in the command shell.
In my case, executing
cmd.exe /X /C "C:\dev\dev-tools\....
from the command line resulted in an OutOfMemoryError.
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>
If anyone is including a custom argLine argument, you must reconsider because it is likely the source of your issues with the memory allocation.
For Example (I used to have):
<argLine>XX:MaxPermSize=4096m ${argLine}</argLine>
Now I use hard specified values:
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
For whatever reason, Applications that integrate with Surefire such as Jacoco, dont request enough memory to coexist with the testing that happens at build time.
(more information can also be found at this s.o. question (1))
(1)-maven jacoco: not generating code coverage report
Writing here the strategy that i used to help others who are stuck with this problem.
It is possible to leverage the SecurityManager to throw an exception when System.exit() is called. you can then examine the stack trace to see exactly who called exit().
This is especially useful if the call to exit was made from code hidden inside one of the jars you are depending on and not from your own code.
private static void forbidSystemExitCall() {
final SecurityManager securityManager = new SecurityManager() {
public void checkPermission( Permission permission ) {
if( permission.getName().startsWith("exitVM") ) {
throw new RuntimeException("Something called exit ") ;
}
}
} ;
System.setSecurityManager( securityManager ) ;
}
Following Maven Surefire documentation, you can execute the forked VM in debug mode, if it always fails. You can then debug your code until it exit.
FWIW, I have experienced this error when the JVM ran out of memory during the maven build. On linux this was detected by OOM killer, which ended up generating kernel messages like
Aug 28 20:53:27 ip-xxx-xxx-xxx-xxx kernel: [248686.775455] java invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0.
I guess on a mac you'd just want to monitor your memory usage with ActivityMonitor.
What you may want to check is the argline setting for surefire or failsafe in build/pluging/plugin config in your pom. I had something improper in there that caused the forked vm to fail (Ironically, i put maven.failsafe.debug in there to help debug an earlier forking crash).
JVM options that can help:
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=c:/dumps/
Note: You can use forward slashes.
Note 2: Make sure the folder exists and that the process has write permission. On recent windows systems, C:\ is write protected.
Note 3: Make sure you have enough free space to write the dump. The Java 9 documentation mentions that the system's temp folder will be used when the disk is full.
If there is no dump file, then you JVM didn't run out of memory.
The next option is -XX:ErrorFile= which allows to the JVM to log fatal errors.
-XX:+ShowMessageBoxOnError shows an error dialog if the JVM crashes.
Note: You can change the flags of a running JVM using the jinfo command.
Pass these options to Maven Surefire via the argLine option:
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- -XX:HeapDumpPath=C:\ -XX:+ShowMessageBoxOnError -->
<argLine>#{argLine} -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -XX:HeapDumpPath=H:/dumps/ -XX:ErrorFile=H:/dumps/ -XX:+ShowMessageBoxOnError</argLine>
</configuration>
</plugin>
</plugins>
</build>
The strange #{argLine} at the beginning allows other plugins like Jacoco to inject their options. For this to work, you need to add an empty property:
<properties>
<argLine></argLine> <!-- Fallback when Jacoco isn't active. -->
</properties>
You can verify that it works when the error happens: Maven will then dump the whole command line used to start the forked JVM.
Changing the configuration of the plugin should resolve the problem:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
As suggested in this post and in the main documentation of the plugin.
If you are using Visual Studio Code
I did not do any changes in the pom.xml file or updated any dependency versions
Adding this line to settings.json of Visual Studio Code solved the problem.
"maven.executable.options": "-DforkCount=0",
Consider updating the jacoco-maven-plugin to 0.8.3
e.g
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<excludes>
<exclude>**/schemas/**/*</exclude>
</excludes>
<destFile>${sonar.jacoco.reportPaths}</destFile>
</configuration>
I just delete all the maven repository and run maven clean install. Then the issue is gone.