Bamboo Java Specs publishing fails with java.lang.InterruptedException when using the Maven Exec plugin

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

When publishing Bamboo Java Specs manually using the Maven Exec plugin it fails with java.lang.InterruptedException. Example:

1 mvn clean compile exec:java -Dexec.mainClass=tutorial.PlanSpec -Dexec.args="arg1 arg2"

Diagnosis

When running Bamboo Specs with Maven exec you get a java.lang.InterruptedException:

1 2 3 4 5 6 7 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.371 s [INFO] Finished at: 2021-01-18T18:00:38+11:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project bamboo-specs: An exception occured while executing the Java class. java.lang.InterruptedException -> [Help 1]

Running Maven with the -e flag shows the full Stacktrace as follows:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project bamboo-specs: An exception occured while executing the Java class. java.lang.InterruptedException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project bamboo-specs: An exception occured while executing the Java class. java.lang.InterruptedException at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) 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:305) 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:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) 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:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. java.lang.InterruptedException at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:311) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) 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:305) 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:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) 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:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.RuntimeException: java.lang.InterruptedException at com.atlassian.bamboo.specs.util.IsolatedExecutor.take (IsolatedExecutor.java:68) at com.atlassian.bamboo.specs.util.IsolatedExecutor.access$100 (IsolatedExecutor.java:8) at com.atlassian.bamboo.specs.util.IsolatedExecutor$1.run (IsolatedExecutor.java:48) Caused by: java.lang.InterruptedException at java.util.concurrent.SynchronousQueue.take (SynchronousQueue.java:928) at com.atlassian.bamboo.specs.util.IsolatedExecutor.take (IsolatedExecutor.java:66) at com.atlassian.bamboo.specs.util.IsolatedExecutor.access$100 (IsolatedExecutor.java:8) at com.atlassian.bamboo.specs.util.IsolatedExecutor$1.run (IsolatedExecutor.java:48)

Cause

It's a result of the interplay between the Java Mojo Exec plugin for Maven and the Bamboo Specs internal REST queue. When using the Exec plugin, once it finishes up it interrupts any remaining daemon threads and Bamboo Spec's REST queue has been written to throw an exception if this happens:

By default daemon threads are joined and interrupted once all known non daemon threads have quitted. The join timeout is customisable The user might wish to further cleanup cleanup by stopping the unresponsive threads. The user can disable the full extra thread management (interrupt/join/[stop])

Solution

You can change the default behavior of the Maven Exec plugin so that it doesn't interrupt daemon threads when non daemon threads have finished using the argument -Dexec.cleanupDaemonThreads=false:

1 mvn clean compile exec:java -Dexec.mainClass=tutorial.PlanSpec -Dexec.args="arg1 arg2" -Dexec.cleanupDaemonThreads=false

Updated on March 10, 2025

Still need help?

The Atlassian Community is here for you.