Error exec-maven-plugin, even with a working example

EDIT5 Updated /

I am using Maven 3.3.3.
I simply create a new project and add a compilation plugin and exec, as examples on the Internet.
I tried to execute, but I got an error

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project QNAProject: An exception occured while executing the Java class. com.jadex.qna.QNAProject.App -> [Help 1]<br> [ERROR] <br> [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.<br> [ERROR] Re-run Maven using the -X switch to enable full debug logging.<br> [ERROR] <br> [ERROR] For more information about the errors and possible solutions, please read the following articles:<br> [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException<br> 

I tried exec-maven-plugin versions 1.2.1 and 1.4.0 but got the same error. Here is my 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>com.jadex.qna</groupId> <artifactId>QNAProject</artifactId> <version>0.1</version> <packaging>jar</packaging> <name>QNAProject</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <executable>maven</executable> <mainClass>com.jadex.qna.QNAProject.App</mainClass> </configuration> </plugin> </plugins> </build> </project> 

I even tried a working example project from several sites,
eg,

http://examples.javacodegeeks.com/enterprise-java/maven/create-java-project-with-maven-example/
http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/

but I got the same error.

I unpacked maven in C: \ apache-maven-3.3.3 and created the MAVEN_HOME environment variable as the same path. What is the problem?

======================================

EDIT: Here is the result

enter image description here

Well .. I installed MAVEN_HOME, not M2_HOME, because the tutorial I found said to install it only ...
Of course, echo% MAVEN_HOME% shows

C: \ Apache-Maven-3.3.3

it is not right?

I added% MAVEN_HOME% \ bin to the PATH variable, but it didn't work either.
And I use eclipse

=======================================

EDIT2: Here is the complete magazine. I used the target "clean exec: java -e -X"

It was too long, so I uploaded to my blog here. Please note that I changed the repository folder from C: \ Users ..... m2 to the new local repository folder C: \ apache-maven-localrepository

https://arincblossom.wordpress.com/2015/06/15/error-logs/

=========================================

EDIT3: I changed the maven-compiler-plugin setting like this

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <verbose>true</verbose> <fork>true</fork> <executable>${env.JAVA_HOME}/bin/javac</executable> <compilerVersion>1.5</compilerVersion> <!-- <source>1.8</source> <target>1.8</target> --> </configuration> </plugin> 

This prevented me from getting the error from mvn -e compile exec:java , but I can’t work with mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"

===================================

EDIT4: Okay, I will try from below and publish again. Thank you for your sincere advice.

========================================

EDIT5

I reset all sequences ... re-installed eclipse, maven .. and newly created projects ... but nothing worked ...

I changed the eclipse settings to fix the JDK path to the installed jdk path, not the JRE. then I found that "mvn -e clean compile exec: java" works, but I just want "mvn clean exec: java" to work. This does not work at all.

Here you can check the full source.

https://github.com/arincblossom/MavenTestProject

This is the current console message for "mvn -e clean exec: java"

 [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... @53:5) @ C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5 [WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... @53:5) @ C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5 [WARNING] [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenTestProject 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenTestProject --- [INFO] Deleting C:\Users\bonavision_laptop\Desktop\Project\JadeX\MavenTestProject\MavenTestProject\target [INFO] [INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ MavenTestProject --- [WARNING] java.lang.ClassNotFoundException: com.jadex.qna.MavenTestProject.App at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281) at java.lang.Thread.run(Thread.java:745) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.900 s [INFO] Finished at: 2015-06-15T17:42:19+09:00 [INFO] Final Memory: 8M/153M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project MavenTestProject: An exception occured while executing the Java class. com.jadex.qna.MavenTestProject.App -> [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 
+5
source share
3 answers

The error log that you have indicated indicates the following:

 java.lang.ClassNotFoundException com.jadex.qna.QNAProject.App 

So, it’s clear what the root source of the error is. You are trying to execute the main() method of a class whose Maven class file cannot be found. As stated in this SO article , you can try to compile first and then execute after creating the class file:

 mvn -e compile exec:java mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App" 
+1
source

This problem occurs when it is also not compatible with eclipse.

try it

 mvn clean install eclipse:eclipse 

Vote if it works to help other participants

+2
source

I ran into the same problem, it was caused by a port conflict. my tomcat server tried to start port 8080, but I already had a binding to it. netstat -anto will show you the port bindings 0.0.0.0:8080 or similar, and this is the PID, it will help you determine which process port transfer is already running in, either change it on the timcat server or some process is trying. May be caused by IIS, SKype or similar.

0
source

All Articles