users@glassfish.java.net

Embedded Glassfish 3.1 and Servlet 3.0

From: <glassfish_at_javadesktop.org>
Date: Wed, 20 Oct 2010 04:18:37 PDT

Hi,

I followed this tip of the day http://blogs.sun.com/arungupta/entry/totd_132_servlets_3_0 and came up with a servlet like this:[code]@WebServlet(name = "servlet1", urlPatterns = {"/servlet1"})
public class Servlet1 extends HttpServlet {
    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        logger.debug("Hi!");
    }
}[/code]and a JUnit 4.8 test class like this:[code]public class MainTest {
    @Test
    public void test() throws Throwable {
        Server.Builder builder = new Server.Builder("server");
        Server server = builder.build();
        server.createPort(8282);
        server.addContainer(ContainerBuilder.Type.web);
        ScatteredArchive.Builder saBuilder = new ScatteredArchive.Builder("test",
                Collections.singleton(new File("target/classes").toURI().toURL()));
        ScatteredArchive archive = saBuilder.buildWar();
        EmbeddedDeployer deployer = server.getDeployer();
        deployer.deploy(archive, null);
    }
}[/code]This is what I got when running mvn test:[code]-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running home.glassfish.embedded.MainTest
Return false from isValidInstallRoot
Oct 20, 2010 6:46:40 AM com.sun.enterprise.glassfish.bootstrap.EmbeddedNonOSGiGlassFishRuntimeBuilder provisionInstanceRoot
WARNING: AS_DEF_DOMAINS_PATH is not set.
Oct 20, 2010 6:46:40 AM com.sun.enterprise.glassfish.bootstrap.NonOSGiGlassFishRuntime provisionInstanceRoot
WARNING: AS_DEF_DOMAINS_PATH is not set.
Oct 20, 2010 6:46:41 AM com.sun.enterprise.util.EarlyLogger add
INFO: Total time to parse domain.xml: 164 milliseconds
Oct 20, 2010 6:46:44 AM com.sun.logging.LogDomains$1 log
INFO: GlassFish Server Open Source Edition 3.1-b22 (java_re-private) startup time : Embedded(990ms) startup services(3066ms) total(4056ms)
Oct 20, 2010 6:46:45 AM com.sun.logging.LogDomains$1 log
INFO: enterprise_used_delegate_name
Oct 20, 2010 6:46:45 AM com.sun.logging.LogDomains$1 log
INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Oct 20, 2010 6:46:45 AM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
Oct 20, 2010 6:46:46 AM com.sun.logging.LogDomains$1 log
SEVERE: Module type not recognized for module /var/tmp/att/gfembed5448969889020192693tmp/applications/test
Oct 20, 2010 6:46:46 AM com.sun.logging.LogDomains$1 log
SEVERE: There is no installed container capable of handling this application test
classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7_at_13c53a8
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.812 sec[/code]I tried with embedded glassfish 3.1-SNAPSHOT, b25, b22 and the results are the same (that means the problem is probably not with glassfish).
Thank you.
[Message sent by forum member 'dxxvi']

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