dev@grizzly.java.net

another problem with servletadapter mapping

From: Survivant 00 <survivant00_at_gmail.com>
Date: Fri, 8 May 2009 20:53:38 -0400

thanks JF for the multipath fix.. but now I'm running another test that
failed.

I have a php page index.php in
C:/source/grizzly/modules/http-servlet-deployer/war_php/joomla/index.php


and when I run this testcase.. I received a 200.. but also the content of
index.php, not compiled by the servlet.

there is something that I missed ?

I have the same problem with JSP

public void testDeployAutoServletPHP2() throws IOException {
        System.out.println("testPHP");
        try {
            startGrizzlyWebServer(PORT);
            String[] aliases = new String[] { "*.php" };

            String context = "/";
            String servletPath = "war_php/joomla";
            //String rootFolder = ".";
            String rootFolder =
"C:/source/grizzly/modules/http-servlet-deployer/war_php/";

            // loadons les jars dans le classpath
            GrizzlyWebServerDeployer deployer = new
GrizzlyWebServerDeployer();


deployer.setLibraryPath("C:/source/grizzly/modules/http-servlet-deployer/lib_autodeploy");
            deployer.appendWarContentToClassPath(null);

            ServletAdapter adapter = new ServletAdapter();

            Servlet servlet = (Servlet)
ClassLoaderUtil.load("com.caucho.quercus.servlet.QuercusServlet");
            adapter.setServletInstance(servlet);

            adapter.setContextPath(context);
            adapter.setServletPath(servletPath);
            adapter.setRootFolder(rootFolder);

            gws.addGrizzlyAdapter(adapter, aliases);

            gws.start();

            //WINNER
            // http://localhost:18901/war_autodeploy/php_test/index.php

            String url = context + servletPath + "/index.php";
            HttpURLConnection conn = getConnection(url);
            assertEquals(HttpServletResponse.SC_OK,
getResponseCodeFromAlias(conn));

            System.out.println(readResponse(conn));

            //assertEquals(url, );

        } finally {
            stopGrizzlyWebServer();
        }
    }


testPHP
[main] Fri May 08 20:35:23 EDT 2009 [LE PLUS FIN]
com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer
appendWarContentToClassPath:Classpath
contains=file:/file:/C:/sources/grizzly/code/modules/http-servlet-deployer/webapps/

[main] Fri May 08 20:35:23 EDT 2009 [LE PLUS FIN]
com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer
appendWarContentToClassPath:Classpath
contains=file:/file:/C:/sources/grizzly/code/modules/http-servlet-deployer/war_php/

[main] Fri May 08 20:35:23 EDT 2009 [FIN]
com.sun.grizzly.http.SelectorThread initAlgorithm:Using Algorithm:
com.sun.grizzly.http.algorithms.NoParsingAlgorithm

[main] Fri May 08 20:35:23 EDT 2009 [FIN] com.sun.grizzly.Controller
autoConfigureCore:Controller auto-configured with 2 ReadController based on
underlying cores/processors, with a Thread Pool of maximum size 10

[main] Fri May 08 20:35:23 EDT 2009 [INFO]
com.sun.grizzly.http.PHPGrizzlyWebServerTest getConnection:sending request
to /joomla/index.php

[http18901-WorkerThread(0)] Fri May 08 20:35:23 EDT 2009 [FIN]
com.sun.grizzly.SelectorHandlerRunner dolog:OP_ACCEPT on
sun.nio.ch.SelectionKeyImpl_at_fe64b9 attachment: null

[main] Fri May 08 20:35:23 EDT 2009 [FIN]
sun.net.www.protocol.http.HttpURLConnection
writeRequests:sun.net.www.MessageHeader_at_19616c75 pairs: {GET
/joomla/index.php HTTP/1.1: null}{User-Agent: Java/1.6.0_13}{Host:
localhost:18901}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*;
q=.2}{Connection: keep-alive}

[http18901-WorkerThread(0)] Fri May 08 20:35:23 EDT 2009 [FIN]
com.sun.grizzly.SelectorHandlerRunner dolog:OP_READ on
sun.nio.ch.SelectionKeyImpl_at_b166b5 attachment: 1241829323758

[http18901-WorkerThread(0)] Fri May 08 20:35:23 EDT 2009 [FIN]
com.sun.grizzly.tcp.StaticResourcesAdapter service:File not found
.\joomla\index.php

[http18901-WorkerThread(0)] Fri May 08 20:35:27 EDT 2009 [LE PLUS FIN]
com.sun.grizzly.http.SocketChannelOutputBuffer flushChannel:flushChannel
isAsyncHttpWriteEnabled=false bb=java.nio.HeapByteBuffer[pos=0 lim=166
cap=131072]

[main] Fri May 08 20:35:27 EDT 2009 [FIN]
sun.net.www.protocol.http.HttpURLConnection
getInputStream:sun.net.www.MessageHeader_at_e1899b5 pairs: {null: HTTP/1.1 404
Not Found}{server: grizzly/1.9.16}{Content-Type: text/plain;
charset=iso-8859-1}{Transfer-Encoding: chunked}{Date: Sat, 09 May 2009
00:35:27 GMT}

[http18901-WorkerThread(1)] Fri May 08 20:35:28 EDT 2009 [FIN]
com.sun.grizzly.BaseSelectionKeyHandler$1
locallyClosed:sun.nio.ch.SelectionKeyImpl_at_fe64b9 is being locally cancelled

[http18901-WorkerThread(1)] Fri May 08 20:35:28 EDT 2009 [FIN]
com.sun.grizzly.BaseSelectionKeyHandler$1
locallyClosed:sun.nio.ch.SelectionKeyImpl_at_b166b5 is being locally cancelled



here JSP

public void testComplexAliasMapping() throws IOException {
        System.out.println("testComplexAliasMapping");
        try {
            startGrizzlyWebServer(PORT);
            String[] aliases = new String[] { "/*.jsp" };

            String context = "/test";
            String servletPath = "/servlet";
            String rootFolder = ".";

            //debug
            GrizzlyWebServerDeployer deployer = new
GrizzlyWebServerDeployer();

deployer.setLibraryPath("C:/sources/grizzly/code/modules/http-servlet-deployer/lib_autodeploy");

deployer.appendWarContentToClassPath("C:/sources/grizzly/code/modules/http-servlet-deployer/");

            ServletAdapter adapter = new ServletAdapter();

            Servlet servlet = (Servlet)
ClassLoaderUtil.load("org.apache.jasper.servlet.JspServlet");
            adapter.setServletInstance(servlet);

            adapter.setContextPath(context);
            adapter.setServletPath(servletPath);
            adapter.setRootFolder(rootFolder);

            adapter.addInitParameter("fork", "false");
            adapter.addInitParameter("classpath",
"C:/sources/grizzly/code/modules/http-servlet-deployer/");


            gws.addGrizzlyAdapter(adapter, aliases);

            gws.start();

            //special test
            String url = context + servletPath + "/index.jsp";
            HttpURLConnection conn = getConnection(url);
            assertEquals(HttpServletResponse.SC_OK,
getResponseCodeFromAlias(conn));
            assertEquals(url, readResponse(conn));

        } finally {
            stopGrizzlyWebServer();
        }
    }

I received : allo toi <%=request.getParameter("id")%>

instead of : allo toi /test/servlet/index.jsp

here the log

testComplexAliasMapping
2009-05-08 20:49:38 com.sun.grizzly.http.JSPGrizzlyWebServerTest2
getConnection
INFO: sending request to /test/servlet/index.jsp
2009-05-08 20:49:38 com.sun.grizzly.http.JSPGrizzlyWebServerTest2
readResponse
INFO: received line allo toi <%=request.getParameter("id")%>