users@glassfish.java.net

Re: Embedded example?

From: stephanos <exe2_at_gmx.net>
Date: Fri, 2 Oct 2009 04:37:30 -0700 (PDT)

By the way - this is how far I got:

protected void initServer () throws LifecycleException {

        // cleanup
        File pwd = new File ("./");
        File serverRoot = new File (pwd, SERVER_SUB_PATH);
        if (serverRoot.exists ())
            FileStaticService.deleteFolder (serverRoot);
        File logFile = new File (pwd, "target/server.log");
        logFile.delete ();

        // setup configuration
        EmbeddedFileSystem.Builder info = new EmbeddedFileSystem.Builder ();
        info.installRoot (serverRoot);
        //info.setHttpPort (PORT);

        // initialize
        Server.Builder srvBuild = new Server.Builder (NAME);
        srvBuild.logFile (logFile);
        srvBuild.embeddedFileSystem (info.build ());
        glassfish = srvBuild.build ();
        glassfish.start ();
    }

    public void initWar (final String pPath)
            throws LifecycleException {

        initServer ();

        LoggingStaticService.info ("STARTING GLASSFISH WITH WAR: " +
getBasePath ());

        // load war
        File war = new File (pPath);
        glassfish.getDeployer ().deploy (war, new DeployCommandParameters
());
    }

    public void initScatteredWar ()
            throws IOException, LifecycleException {

        initServer ();

        // load scattered archive
        ScatteredArchive.Builder war = new ScatteredArchive.Builder (NAME,
new File ("target/"));
        war.resources (new File ("src/test/resources"));
        war.addMetadata (new File ("src/test/resources/WEB-INF/web.xml"));
        war.addClassPath (new File ("target/test-classes").toURI ().toURL
());

        LoggingStaticService.info ("STARTING GLASSFISH WITH SCATTERED
ARCHIVE: " + getBasePath ());

        // params
        DeployCommandParameters params = new DeployCommandParameters ();
        params.name = NAME;
        params.contextroot = NAME;

        // deploy
        glassfish.getDeployer ().deploy (war.buildWar (), params);
    }


and I get:
Oct 2, 2009 1:30:45 PM org.glassfish.api.ActionReport failure
SEVERE: Module type not recognized
Oct 2, 2009 1:30:45 PM org.glassfish.api.ActionReport failure
SEVERE: There is no installed container capable of handling this application
org.glassfish.api.embedded.ScatteredArchive_at_54d8fd1a located at target

obviously it doesn't recognize my web.xml.
(also I couldn't figure out how to set the port)
-- 
View this message in context: http://www.nabble.com/Embedded-example--tp25714311p25714338.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.