Minimal example to reproduce the plugin issue.
Problem: when running the example, the process hangs for approximately 10 seconds before exiting with one of two exceptions listed below. The exact exception depends on the code used in the example.
A similar problem is described here: mojohaus/exec-maven-plugin#327 (comment)
Running the example from an IDE such as IntelliJ does not show the problem, the problem occurs only when running the code from command line:
mvn compile exec:javaThis causes the following exception:
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/xbill/DNS/NioTcpClient$ChannelKey
at org.xbill.DNS.NioTcpClient.closeTcp (NioTcpClient.java:70)
at org.xbill.DNS.NioClient.runTasks (NioClient.java:174)
at org.xbill.DNS.NioClient.close (NioClient.java:94)
at org.xbill.DNS.NioClient.lambda$selector$0 (NioClient.java:64)
at java.lang.Thread.run (Thread.java:750)
Caused by: java.lang.NoClassDefFoundError: org/xbill/DNS/NioTcpClient$ChannelKey
at org.xbill.DNS.NioTcpClient.closeTcp (NioTcpClient.java:70)
at org.xbill.DNS.NioClient.runTasks (NioClient.java:174)
at org.xbill.DNS.NioClient.close (NioClient.java:94)
at org.xbill.DNS.NioClient.lambda$selector$0 (NioClient.java:64)
at java.lang.Thread.run (Thread.java:750)
Caused by: java.lang.ClassNotFoundException: org.xbill.DNS.NioTcpClient$ChannelKey
at org.codehaus.mojo.exec.URLClassLoaderBuilder$ExecJavaClassLoader.loadClass (URLClassLoaderBuilder.java:211)
at java.lang.ClassLoader.loadClass (ClassLoader.java:351)
at org.xbill.DNS.NioTcpClient.closeTcp (NioTcpClient.java:70)
at org.xbill.DNS.NioClient.runTasks (NioClient.java:174)
at org.xbill.DNS.NioClient.close (NioClient.java:94)
at org.xbill.DNS.NioClient.lambda$selector$0 (NioClient.java:64)
at java.lang.Thread.run (Thread.java:750)Alternatively, by commenting out the first line in the example and using the second line instead, we get:
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy (ThreadGroup.java:778)
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:335)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)In both cases the work around is to comment out the last line in the example. The last line instantiates the error-causing classes before the process is shutting down.