You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Hinkle, Cameron" <Ca...@nike.com> on 2010/11/01 16:55:12 UTC

Surefire NPE

Greetings,

I've been using Maven and Surefire on a project for about a year now and have sporadically seen a problem that I've always been able to get around but want to get to the bottom of.  It's a null pointer exception sometimes when I run "mvn" and it tries to run all our tests.  It happens rarely but four different people on the project have run into it at one point or another.  For some reason if I bypass the tests and start my Jetty server through maven, I can go back to run the tests after stopping Jetty and the tests run just fine.  This is typically my workaround.

Here is the output from the command line:

C:\workspaces\tesla\readiness-mobile\tesla-src-mobile>mvn
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Templated Service Layer Assembler
[INFO]    task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
Downloading: http://repo1.maven.org/maven2/com/nike/classes/2.2/classes-2.2.pom
[INFO] Unable to find resource 'com.nike:classes:pom:2.2' in repository central (http://repo1.maven.org/maven2)
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to C:\workspaces\tesla\readiness-mobile\tesla-src-mobile\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 76 resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\workspaces\tesla\readiness-mobile\tesla-src-mobile\target\surefire-reports
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:394)
        at java.util.Properties.setProperty(Properties.java:143)
        at org.apache.maven.surefire.booter.SurefireBooter.setForkProperties(SurefireBooter.java:510)
        at org.apache.maven.surefire.booter.SurefireBooter.forkSuites(SurefireBooter.java:483)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesForkOnce(SurefireBooter.java:385)
        at org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:246)
        at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:581)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Mon Nov 01 08:49:35 PDT 2010
[INFO] Final Memory: 19M/46M
[INFO] ------------------------------------------------------------------------
C:\workspaces\tesla\readiness-mobile\tesla-src-mobile>

And here is the Surefire configuration in the pom.xml:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <additionalClasspathElements>
            <additionalClasspathElement>${resource-bundle-path}</additionalClasspathElement>
          </additionalClasspathElements>
        </configuration>
      </plugin>

I'm thinking this is probably a bug in Maven or Surefire but I can't find any mention of it on Google.  Has anyone run into this or know what causes it?

Thanks,
Cameron

Cameron Hinkle  |  Senior Application Engineer  |  Nike DCIT  |  503.532.3075  |  7. Evolve Immediately |


Re: Surefire NPE

Posted by Cameron <Ca...@nike.com>.
I've tried hard coding the resource bundle path and I get the same result. 
And it only happens about half the time, regardless.

Judging by the stack trace, the problem is somehow related to what happens
when Surefire forks so that the tests run in their own JVM process.  When I
set "forkMode" to "never", I don't get the error any more but several of my
tests fail because they require their own process.

Let me know if anyone has any other ideas.
-- 
View this message in context: http://maven.40175.n5.nabble.com/Surefire-NPE-tp3246444p3258956.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire NPE

Posted by Ben Hsu <be...@bluefly.com>.
Blind guess: maybe ${resource-bundle-path} is being set to a different value
when the user runs it?

On Mon, Nov 1, 2010 at 11:55 AM, Hinkle, Cameron <Ca...@nike.com>wrote:

> Greetings,
>
> I've been using Maven and Surefire on a project for about a year now and
> have sporadically seen a problem that I've always been able to get around
> but want to get to the bottom of.  It's a null pointer exception sometimes
> when I run "mvn" and it tries to run all our tests.  It happens rarely but
> four different people on the project have run into it at one point or
> another.  For some reason if I bypass the tests and start my Jetty server
> through maven, I can go back to run the tests after stopping Jetty and the
> tests run just fine.  This is typically my workaround.
>
> Here is the output from the command line:
>
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile>mvn
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Templated Service Layer Assembler
> [INFO]    task-segment: [package]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [resources:resources {execution: default-resources}]
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 6 resources
> Downloading:
> http://repo1.maven.org/maven2/com/nike/classes/2.2/classes-2.2.pom
> [INFO] Unable to find resource 'com.nike:classes:pom:2.2' in repository
> central (http://repo1.maven.org/maven2)
> [INFO] [compiler:compile {execution: default-compile}]
> [INFO] Compiling 1 source file to
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile\target\classes
> [INFO] [resources:testResources {execution: default-testResources}]
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 76 resources
> [INFO] [compiler:testCompile {execution: default-testCompile}]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [surefire:test {execution: default-test}]
> [INFO] Surefire report directory:
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile\target\surefire-reports
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] null
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Trace
> java.lang.NullPointerException
>        at java.util.Hashtable.put(Hashtable.java:394)
>        at java.util.Properties.setProperty(Properties.java:143)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.setForkProperties(SurefireBooter.java:510)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.forkSuites(SurefireBooter.java:483)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesForkOnce(SurefireBooter.java:385)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:246)
>        at
> org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:581)
>        at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>        at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>        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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>        at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 6 seconds
> [INFO] Finished at: Mon Nov 01 08:49:35 PDT 2010
> [INFO] Final Memory: 19M/46M
> [INFO]
> ------------------------------------------------------------------------
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile>
>
> And here is the Surefire configuration in the pom.xml:
>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-surefire-plugin</artifactId>
>        <version>2.5</version>
>        <configuration>
>          <additionalClasspathElements>
>
>  <additionalClasspathElement>${resource-bundle-path}</additionalClasspathElement>
>          </additionalClasspathElements>
>        </configuration>
>      </plugin>
>
> I'm thinking this is probably a bug in Maven or Surefire but I can't find
> any mention of it on Google.  Has anyone run into this or know what causes
> it?
>
> Thanks,
> Cameron
>
> Cameron Hinkle  |  Senior Application Engineer  |  Nike DCIT  |
>  503.532.3075  |  7. Evolve Immediately |
>
>

Re: Surefire NPE

Posted by Ben Hsu <be...@bluefly.com>.
Blind guess: maybe ${resource-bundle-path} is being set to a different value
when the user runs it?

On Mon, Nov 1, 2010 at 11:55 AM, Hinkle, Cameron <Ca...@nike.com>wrote:

> Greetings,
>
> I've been using Maven and Surefire on a project for about a year now and
> have sporadically seen a problem that I've always been able to get around
> but want to get to the bottom of.  It's a null pointer exception sometimes
> when I run "mvn" and it tries to run all our tests.  It happens rarely but
> four different people on the project have run into it at one point or
> another.  For some reason if I bypass the tests and start my Jetty server
> through maven, I can go back to run the tests after stopping Jetty and the
> tests run just fine.  This is typically my workaround.
>
> Here is the output from the command line:
>
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile>mvn
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Templated Service Layer Assembler
> [INFO]    task-segment: [package]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [resources:resources {execution: default-resources}]
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 6 resources
> Downloading:
> http://repo1.maven.org/maven2/com/nike/classes/2.2/classes-2.2.pom
> [INFO] Unable to find resource 'com.nike:classes:pom:2.2' in repository
> central (http://repo1.maven.org/maven2)
> [INFO] [compiler:compile {execution: default-compile}]
> [INFO] Compiling 1 source file to
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile\target\classes
> [INFO] [resources:testResources {execution: default-testResources}]
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 76 resources
> [INFO] [compiler:testCompile {execution: default-testCompile}]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [surefire:test {execution: default-test}]
> [INFO] Surefire report directory:
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile\target\surefire-reports
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] null
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Trace
> java.lang.NullPointerException
>        at java.util.Hashtable.put(Hashtable.java:394)
>        at java.util.Properties.setProperty(Properties.java:143)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.setForkProperties(SurefireBooter.java:510)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.forkSuites(SurefireBooter.java:483)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesForkOnce(SurefireBooter.java:385)
>        at
> org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:246)
>        at
> org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:581)
>        at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>        at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>        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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>        at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 6 seconds
> [INFO] Finished at: Mon Nov 01 08:49:35 PDT 2010
> [INFO] Final Memory: 19M/46M
> [INFO]
> ------------------------------------------------------------------------
> C:\workspaces\tesla\readiness-mobile\tesla-src-mobile>
>
> And here is the Surefire configuration in the pom.xml:
>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-surefire-plugin</artifactId>
>        <version>2.5</version>
>        <configuration>
>          <additionalClasspathElements>
>
>  <additionalClasspathElement>${resource-bundle-path}</additionalClasspathElement>
>          </additionalClasspathElements>
>        </configuration>
>      </plugin>
>
> I'm thinking this is probably a bug in Maven or Surefire but I can't find
> any mention of it on Google.  Has anyone run into this or know what causes
> it?
>
> Thanks,
> Cameron
>
> Cameron Hinkle  |  Senior Application Engineer  |  Nike DCIT  |
>  503.532.3075  |  7. Evolve Immediately |
>
>