users@glassfish.java.net

Embedded server NPEs

From: <glassfish_at_javadesktop.org>
Date: Wed, 07 Apr 2010 05:36:41 PDT

Hello. I followed the instructions in http://docs.sun.com/app/docs/doc/821-1208/giiab?a=view while I was creating an embedded server for unit testing.

If I attempt to set the installRoot of the embedded file system, Glassfish embedded throws the following error:

java.lang.NullPointerException
        at com.sun.enterprise.glassfish.bootstrap.ASMainStatic.insertURLs(ASMainStatic.java:394)
        at com.sun.enterprise.glassfish.bootstrap.ASMainStatic.createTmpClassLoader(ASMainStatic.java:334)
        at com.sun.enterprise.glassfish.bootstrap.ASMainStatic.run(ASMainStatic.java:125)
        at com.sun.enterprise.glassfish.bootstrap.AbstractMain.start(AbstractMain.java:78)
        at org.glassfish.api.embedded.Server.<init>(Server.java:288)
        at org.glassfish.api.embedded.Server.<init>(Server.java:61)
        at org.glassfish.api.embedded.Server$Builder.build(Server.java:158)
        at org.glassfish.api.embedded.Server$Builder.build(Server.java:140)

My code does this:

    final Server.Builder builder = new Server.Builder("test");
    builder.logger(true);

    final File mavenProjectBuildDirectory = new File(System.getProperty("maven.project.build.directory", "./target")); // I pass this as a System property; it's non-null
    Assert.assertTrue(mavenProjectBuildDirectory.isDirectory());

    final EmbeddedFileSystem.Builder fileSystemBuilder = new EmbeddedFileSystem.Builder();

    final EmbeddedFileSystem embeddedFileSystem = fileSystemBuilder.installRoot(mavenProjectBuildDirectory).build();
    Assert.assertNotNull(embeddedFileSystem);

    builder.embeddedFileSystem(embeddedFileSystem);

    this.server = builder.build();
    Assert.assertNotNull(this.server);
    this.server.createPort(9090);
    this.server.start();

What am I doing wrong, given that I've followed the product documentation instructions?

Thanks,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=395670