java-ee angular - Running daemon with exec-maven-plugin avoiding `IllegalThreadStateException`

build project (3)

You can also pass cleanupDaemonThreads using the command line parameter:



export MAVEN_OPTS=-Dfile.encoding=utf-8

mvn exec:java \ 
     -Dexec.cleanupDaemonThreads=false \ 
     -Dexec.mainClass="" -Dexec.args="$PARAMS"

I would like to run a daemon thread which should start on maven package phase. This is what I have in pom.xml:


And here is the content of the class Startup:

public class Startup {

    public static class Testing extends Thread {
        public void run() {
            while(true) {

    public static void main(String[] list) throws Exception {
        Testing t = new Testing();

The thread starts to run but the compile stops while the thread is running. After some time (timeout or something) the thread stops and the compilation continues. Is there anyway I can get this thread to start on the background and make the compilation continue on its own?

Some output from the maven:

[WARNING] thread Thread[Thread-1,5,com.test.Startup] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[Thread-1,5,com.test.Startup] will linger despite being asked to die via interruption
[WARNING] NOTE: 1 thread(s) did not finish despite being asked to  via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=com.test.Startup,maxpri=10]
    at java.lang.ThreadGroup.destroy(
    at org.codehaus.mojo.exec.ExecJavaMojo.execute(
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
    at org.apache.maven.DefaultMaven.doExecute(
    at org.apache.maven.DefaultMaven.execute(
    at org.apache.maven.cli.MavenCli.execute(
    at org.apache.maven.cli.MavenCli.doMain(
    at org.apache.maven.cli.MavenCli.main(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(

I am planning to create a socket listener to this thread and let it live in the background as long as the maven shuts the JVM down but currently it seems the socket will be on only for some time during the compilation.

Posting the answer that is discussed in the comments section of the question. This solution worked for me! Thanks Andrew Logvinov

cleanupDaemonThreads = false

Something like this in the configuration tag

<configuration> <mainClass>com.test.Startup</mainClass> <cleanupDaemonThreads>false</cleanupDaemonThreads> </configuration>

struts.xml is the Struts2 configuration file struts-config.xml while is the name generally has the Struts configuration file (1.3.x)

java-ee maven jboss exec-maven-plugin