You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I am trying to do, is to create a java class (PrimitiveServlet.class) file by javac, and then use URLClassLoader to load this class file dynamically.
To reproduce the bug using exec-maven-plugin, run the following command:
The first command is to create the class file, the third command is to run the whole program.
Error Information:
java.lang.NoClassDefFoundError: javax/servlet/Servlet
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:1016)
at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:174)
at java.net.URLClassLoader.defineClass (URLClassLoader.java:550)
at java.net.URLClassLoader$1.run (URLClassLoader.java:458)
at java.net.URLClassLoader$1.run (URLClassLoader.java:452)
at java.security.AccessController.doPrivileged (Native Method)
at java.net.URLClassLoader.findClass (URLClassLoader.java:451)
at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
at org.syh.demo.App.main (App.java:25)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:279)
at java.lang.Thread.run (Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javax.servlet.Servlet
at java.net.URLClassLoader.findClass (URLClassLoader.java:471)
at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:1016)
at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:174)
at java.net.URLClassLoader.defineClass (URLClassLoader.java:550)
at java.net.URLClassLoader$1.run (URLClassLoader.java:458)
at java.net.URLClassLoader$1.run (URLClassLoader.java:452)
at java.security.AccessController.doPrivileged (Native Method)
at java.net.URLClassLoader.findClass (URLClassLoader.java:451)
at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
at org.syh.demo.App.main (App.java:25)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:279)
at java.lang.Thread.run (Thread.java:834)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.111 s
[INFO] Finished at: 2022-08-01T21:21:09-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:java (default-cli) on project exec-plugin-issue: An exception occurred while executing the Java class. javax/servlet/Servlet: javax.servlet.Servlet
However, if we use pure java command to run the program, the code can work without any error:
Minimal reproducer project: https://github.com/Kirchoffs/exec-plugin-issue
What I am trying to do, is to create a java class (PrimitiveServlet.class) file by javac, and then use URLClassLoader to load this class file dynamically.
To reproduce the bug using exec-maven-plugin, run the following command:
The first command is to create the class file, the third command is to run the whole program.
Error Information:
However, if we use pure java command to run the program, the code can work without any error:
The text was updated successfully, but these errors were encountered: