users@glassfish.java.net

ScatteredArchive + persistence = NPE (GF 3.0)

From: <glassfish_at_javadesktop.org>
Date: Mon, 29 Mar 2010 19:05:21 PDT

Hello,


Here is the code I use to deploy my app as an exploded war from my IDE (with GF 3.0):
[code]

        System.setProperty("basedir", System.getProperty("user.dir"));

        Server server = new Server.Builder("web").build();

        File webappDir = new File(System.getProperty("basedir"));
        webappDir = new File(webappDir,"src/main/webapp");
        File classesDir = new File(System.getProperty("basedir"));
        classesDir = new File(classesDir,"target/classes");
        ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", webappDir);
        builder.addClassPath(classesDir.toURI().toURL());
        ScatteredArchive war = builder.buildWar();
        System.out.println("War content");
        Enumeration<String> contents = war.entries();
        while(contents.hasMoreElements()) {
            System.out.println(contents.nextElement());
        }
        Port port = server.createPort(8080);
         server.addContainer(server.createConfig(ContainerBuilder.Type.ejb));
        server.addContainer(server.createConfig(ContainerBuilder.Type.web));

         DeployCommandParameters dp = new DeployCommandParameters(webappDir);
          EmbeddedDeployer embeddedDeployer = server.getDeployer();
        
          String appName = embeddedDeployer.deploy(war, dp);
[/code]

This works fine as long as I don;t require persistence.


If I add a persistence unit to the mix, glassfish goes on a hunt for persistence.xml in the classpath. But because ScatteredArchive::getSubArchive always returns null (it inherits from ReadableArchiveAdapter), I get a NPE in WarPersistenceArchivist.open:

[code]
java.lang.NullPointerException
        at com.sun.enterprise.deployment.archivist.WarPersistenceArchivist.open(WarPersistenceArchivist.java:92)
        at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:383)
        at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:373)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:238)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:247)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:208)
        at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:148)
        at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:155)
        at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:78)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:612)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:554)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:262)
        at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
        at EmbeddedGF.main(EmbeddedGF.java:47)
[/code]


Is this because ScatteredWar is only partially supported in 3.0, or because I'm doing something wrong? Should I be providing my own implementation of ScatteredArchive?


Thanks,

Vincent
[Message sent by forum member 'toto_laricot']

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