1

I am having an issue building my projects with tests using maven. It works fine just for the project itself. And I didnt have this problem a couple of weeks ago, so I am not really sure what introduced it either.

I have a stack trace of the waiting thread. I have tried building with maven-2.0.11 and 3.0.4 with same results.

"main" prio=5 tid=7fb301801000 nid=0x10e6d9000 in Object.wait() [10e6d7000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <7f3078728> (a java.lang.UNIXProcess)
    at java.lang.Object.wait(Object.java:485)
    at java.lang.UNIXProcess.waitFor(UNIXProcess.java:115)
    - locked <7f3078728> (a java.lang.UNIXProcess)
    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:151)
    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:88)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:191)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:98)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:200)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:177)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Has anyone seen this or have any ideas to resolve this issue?

B B
  • 149
  • 2
  • 15

1 Answers1

0

It's possible that a test is getting stuck during execution.

You can try using the debugForkedProcess option of the surefire plugin. Configure it with something like:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.16</version>
    <configuration>
        <debugForkedProcess>true</debugForkedProcess>
    </configuration>
</plugin>

then put breakpoints in your unit test code and attach a debugger.

Another option is to add timeouts to your tests. For JUnit 4, add the following:

@Test(timeout=10000)
public void testMe()
{
    ...
}

You can also do this globally as suggested here:

@Rule
public Timeout globalTimeout = new Timeout(10000);

Then if one or more of the tests are getting stuck you can look at the test failures and work out exactly where it is happening. Though if the tests are getting stuck in a @Before or @After the timeout will likely not pick this up.

Community
  • 1
  • 1
prunge
  • 22,460
  • 3
  • 73
  • 80