0

I have struggle in using the exec:java plugin in a multi-modules maven project.

After using this command: mvn clean compile exec:java -Dexec.mainClass="com.ade.logic.ServerInitializer" it produces the snippet below. This means, it is about the classpath of the main method? I already try some variants, like first using mvn clean compile and then execute the main method with the exec:java or by defining the classMain on the pom.xml (in the parent pom.xml or in the submodule). I don't know if this problem is from the modules itself. I'm losing some step?

It would be helpful if you'd give me guidelines to issue this problem. Thanks!

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] chat_app [pom]
[INFO] common [jar]
[INFO] service [jar]
[INFO] clientapp [jar]
[INFO] 
[INFO] --------------------------< com.ade:chat_app >--------------------------
[INFO] Building chat_app 1.0-SNAPSHOT [1/4]
[INFO] from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- clean:3.2.0:clean (default-clean) @ chat_app ---
[INFO] 
[INFO] --- exec:3.6.3:java (default-cli) @ chat_app ---
[WARNING] 
java.lang.ClassNotFoundException: com.ade.logic.ServerInitializer
 at org.codehaus.mojo.exec.URLClassLoaderBuilder$ExecJavaClassLoader.loadClass (URLClassLoaderBuilder.java:211)
 at java.lang.ClassLoader.loadClass (ClassLoader.java:528)
 at org.codehaus.mojo.exec.AbstractExecJavaBase.doExecClassLoader (AbstractExecJavaBase.java:376)
 at org.codehaus.mojo.exec.AbstractExecJavaBase.lambda$execute0ドル (AbstractExecJavaBase.java:287)
 at java.lang.Thread.run (Thread.java:1575)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for chat_app 1.0-SNAPSHOT:
[INFO] 
[INFO] chat_app ........................................... FAILURE [ 0.284 s]
[INFO] common ............................................. SKIPPED
[INFO] service ............................................ SKIPPED
[INFO] clientapp .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.711 s
[INFO] Finished at: 2025年12月27日T19:07:08-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.6.3:java (default-cli) on project chat_app: An exception occurred while executing the Java class. com.ade.logic.ServerInitializer -> [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

Here is the list of only directories from the project if it is useful.

.
├── clientapp
|
...more modules...
|
|
└── service
 ├── src
 │  ├── main
 │  │  └── java
 │  │  └── com
 │  │  └── ade
 │  │  └── logic
 │  └── test
 │  └── java
 │  └── com
 │  └── ade
 └── target
 ├── classes
 │  └── com
 │  └── ade
 │  └── logic
 ├── generated-sources
 │  └── annotations
 └── maven-status
 └── maven-compiler-plugin
 └── compile
 └── default-compile
asked Dec 28, 2025 at 1:31
4
  • 1
    Maven is trying to call exec plugin on chat_app module and telling you there is no class com.ade.logic.ServerInitializer the classpath of that module. So unless the class is in that module youre probably missing a dependency declaration of some other module in your repo. Commented Dec 28, 2025 at 6:28
  • 2
    Can you add information on where is the class com.ade.logic.ServerInitializer within your project? And the pom.xml of the chat_app module. I think exec plugin may also try to execute on all modules, that might no be what you want. Commented Dec 28, 2025 at 6:36
  • This question is similar to: How to execute a different goal for one module of a multi module project?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented 2 days ago
  • As mentioned in the linked question, you can run the com.ade.logic.ServerInitializer using mvn -pl service exec:java -Dexec.mainClass="com.ade.logic.ServerInitializer" but you might want to use mvn clean compile or mvn -pl service -amd clean compile first to ensure everything is compiled. Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.