0

I asked here first... but not concluded. Please look at this post first.

exec-maven-plugin error, even on working example


=== Current situation ===

  1. I modified JDK path fixed forcibly for eclipse java build path and project build path.
  2. I can compile now. (with 'mvn -e compile exec:java')
  3. But I can't run. (with 'mvn -e clean exec:java') Maven does not find my mainClass
  4. I tried to explicitly declared my main class with 'mvn -e clean exec:java -Dexec.mainClass=com.jadex.qna.MavenTestProject.App'. But it gives me same error result.

=== Data ===

Here is my full code (including pom.xml, You can open project with eclipse)

https://github.com/arincblossom/MavenTestProject

This is error log shown when I run the project with 'mvn -e clean exec:java' (Same with EDIT5 from previous post)

[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



Is there any way to solve it? I'm stuck in this for 4 days now... Please help T_T

Community
  • 1
  • 1
Prunus Nira
  • 107
  • 1
  • 1
  • 11

1 Answers1

1

If you run mvn clean exec:java all compiled classes are removed by clean so exec:java cannot find it's class to execute.

If you run mvn clean compile exec:java. clean remove all compiled classes which might be there from a previous biuld. compile compile all source codes and exec:java execute the specified class.

If the output is not what do you expect, maybe you should better describe what you want to achive.

output

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenTestProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ MavenTestProject ---
[INFO] Deleting /tmp/MavenTestProject/target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ MavenTestProject ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/MavenTestProject/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ MavenTestProject ---
[INFO] Compiling 1 source file to /tmp/MavenTestProject/target/classes
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ MavenTestProject ---
Hello World!?
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.934s
[INFO] Finished at: Mon Jun 15 12:08:36 CEST 2015
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
SubOptimal
  • 22,518
  • 3
  • 53
  • 69