dev@grizzly.java.net

Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer

From: Bongjae Chang <carryel_at_korea.com>
Date: Tue, 1 Sep 2009 08:45:03 +0900

It's my pleasure. :)

Thanks!

--
Bongjae Chang


  ----- Original Message -----
  From: Survivant 00
  To: dev_at_grizzly.dev.java.net
  Sent: Tuesday, September 01, 2009 8:38 AM
  Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


  thanks for the issue+patch+test :)

  it's fixed


  Commit
  C:\Source\grizzly\modules\bundles\http-servlet-deployer\src\main\java\com\sun\grizzly\http\servlet\deployer\GrizzlyWebServerDeployer.java
  C:\Source\grizzly\modules\bundles\http-servlet-deployer\src\main\java\com\sun\grizzly\http\servlet\deployer\GrizzlyWebServerDeployer.java
  At revision: 3570


  2009/8/31 Bongjae Chang <carryel_at_korea.com>

    Thank you, Sebastien!

    --
    Bongjae Chang


      ----- Original Message -----
      From: Survivant 00
      To: dev_at_grizzly.dev.java.net
      Sent: Monday, August 31, 2009 11:24 PM
      Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


      ah ah ah..  no idea how this one pass all our tests :(


      in the log :

      [main] Mon Aug 31 10:22:17 EDT 2009 [LE PLUS FIN] com.sun.grizzly.http.servlet.d
      eployer.GrizzlyWebServerDeployer deploy:sa alias=[/simple_war/simple_servlet/simple_servlet/*]

      java -Djava.util.logging.config.file=C:/source/logging.properties -jar grizzly-http-servlet-deployer-1.9.18-SNAPSHOT.jar --application=c:\temp\simple_war.war


      the sevlet respond but with this URL : http://localhost:8080/simple_war/simple_servlet/simple_servlet

      I'll fill a bug and fix this.



      2009/8/31 Bongjae Chang <carryel_at_korea.com>

        I attached the test web app(simple_war.war).
        Â
        The simple_war.war includes web.xml, SimpleServlet.java and SimpleServlet.class.
        Â
        web.xml is here.
        ---
        <web-app>
        Â Â <servlet>
        Â Â Â Â Â <servlet-name>SimpleServlet</servlet-name>
        Â Â Â Â Â <servlet-class>SimpleServlet</servlet-class>
        Â Â Â Â Â ...
        Â Â </servlet>
        Â Â <servlet-mapping>
        Â Â Â Â Â <servlet-name>SimpleServlet</servlet-name>
        Â Â Â Â Â <url-pattern>/simple_servlet/*</url-pattern>
        Â Â </servlet-mapping>
        </web-app>
        ---
        Â
        I ran the application with JDK6 on Windows like this:
        Â
        ---
        java -jar grizzly-http-servlet-deployer.jar --application=c:\simple_war.war --port=8080
        Â
        or
        Â
        java -cp grizzly-http-servlet-deployer.jar com.sun.grizzly.http.servlet.deployer.GrizzlyWebServerDeployer --application=c:\simple_war.war --port=8080
        ---
        Â
        And I requested "http://localhost:8080/simple_war/simple_servlet" or "http://localhost:8080/simple_war/simple_servlet/abc" with IE6.
        Â
        I think that the browser should print "Hello, SimpleServlet!".
        Â
        And I think that you can reproduce it easily with the attached .war.
        Â
        Thanks!
        Â
        --
        Bongjae Chang
        Â
        Â
          ----- Original Message -----
          From: Survivant 00
          To: dev_at_grizzly.dev.java.net
          Sent: Monday, August 31, 2009 10:27 PM
          Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


          thanks.


          2009/8/31 Bongjae Chang <carryel_at_korea.com>

            Hi Sebastien,
            Ã‚Â
            Okay! I will try to make a simple .war for reproducing this issue in a few hours and will attach it.
            Ã‚Â
            Thanks!
            --
            Bongjae Chang
            Ã‚Â
            Ã‚Â
              ----- Original Message -----
              From: Survivant 00
              To: dev_at_grizzly.dev.java.net
              Sent: Monday, August 31, 2009 9:41 PM
              Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


              will try that on debug tonight.


              the mapping doesn't look special. I think grizzly-twitter have the same things.. /words/  something like that.

              I'll check.


              can you package a .war that I can test. Will be easier to test.. with the command line you use please.




              2009/8/31 Bongjae Chang <carryel_at_korea.com>

                Hi Sebastien,
                Ãƒâ€šÃ‚Â
                Thank you for your reply.
                Ãƒâ€šÃ‚Â
                I think that maybe your last reply is concerned about the following.
                Ãƒâ€šÃ‚Â
                ---
                Ãƒâ€šÃ‚ Ã‚ if (appliPath != null && appliPath.endsWith(File.pathSeparator)) {
                Ãƒâ€šÃ‚ Ã‚ Â Â Â appliPath = appliPath + File.pathSeparator;
                Ãƒâ€šÃ‚ Ã‚ }
                ---
                I see...
                Ãƒâ€šÃ‚Â
                But, I think that definately, the following code is not correct.
                Ãƒâ€šÃ‚Â
                ---
                mapping = urlPattern.substring(urlPattern.indexOf(sa.getServletPath()));
                ---
                Ãƒâ€šÃ‚Â
                After you will review it, please let me know. :)
                Ãƒâ€šÃ‚Â
                Thanks!
                Ãƒâ€šÃ‚Â
                --
                Bongjae Chang
                Ãƒâ€šÃ‚Â
                Ãƒâ€šÃ‚Â
                  ----- Original Message -----
                  From: Survivant 00
                  To: dev_at_grizzly.dev.java.net
                  Sent: Thursday, August 27, 2009 6:59 PM
                  Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


                  it's to early in the morning to think about it.. will come back to you later.

                  but here what's in the help


-a, --application=[path]* Application(s) path(s). Application(s) deployed can be :
                              Servlet(s), war(s) and expanded war folder(s). To deploy multiple applications use File.pathSeparator Example : -a /app.war:/servlet/web.xml:/warfolder/








                  2009/8/27 Bongjae Chang <carryel_at_korea.com>

                    Hi,
                    Ãƒâ€šÃ‚Â
                    I deployed an web application with using GrizzlyWebServerDeploy, I found that the Servlet is not served because of wrong path mapping.
                    Ãƒâ€šÃ‚Â
                    Here is the example of web.xml
                    ---
                    <web-app>
                    <servlet>
                    Ãƒâ€šÃ‚ Ã‚ <servlet-name>TestServlet</servlet-name>
                    Ãƒâ€šÃ‚ Ã‚ <servlet-class>my.test.TestServlet</servlet-class>
                    </servlet>
                    <servlet-mapping>
                    Ãƒâ€šÃ‚ Ã‚ <servlet-name>TestServlet</servlet-name>
                    Ãƒâ€šÃ‚ Ã‚ <url-pattern>/test/*</url-pattern>
                    </servlet-mapping>
                    ...
                    </web-app>
                    ---
                    Ãƒâ€šÃ‚Â
                    Assuming that context path is "/example",
                    Ãƒâ€šÃ‚Â
                    When I requested http://localhost:port/examples/test/abc, I expected that the TestServlet was serviced.
                    Ãƒâ€šÃ‚Â
                    When I debugged, I found some strange codes.
                    Ãƒâ€šÃ‚Â
                    In GrizzlyWebServerDeploy.java
                    ---
                    public String[] getAlias(ServletAdapter sa, Collection<String> aliases) {
                    Ãƒâ€šÃ‚ Ã‚ ...
                    Ãƒâ€šÃ‚ Ã‚ for( String urlPattern : aliases) {
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â String mapping = "";
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â if (!sa.getServletPath().equals(urlPattern) && urlPattern.indexOf(sa.getServletPath()) > -1) {
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â Â Â Â mapping = urlPattern.substring(urlPattern.indexOf(sa.getServletPath()));
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â }
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â String aliasTmp = sa.getContextPath() + sa.getServletPath() + mapping;
                    Ãƒâ€šÃ‚ Ã‚ }
                    Ãƒâ€šÃ‚ Ã‚ ...
                    }
                    Ãƒâ€šÃ‚Â
                    When I deployed the web app, sa.getServletPath() is equal to "/test" and urlPattern is equal to "/test/*".
                    Ãƒâ€šÃ‚Â
                    Then mapping result is equal to "/test/*" , so aliasTmp result is equal to "/example/test/test/*".
                    Ãƒâ€šÃ‚Â
                    But I think that aliasTmp should become to be "/examples/test/*".
                    Ãƒâ€šÃ‚Â
                    When I edited the mapping code like this experimentally,
                    Ãƒâ€šÃ‚Â
                    ---
                    mapping = urlPattern.subString(urlPattern.indexOf(sa.getServletPath()) + sa.getServletPath().length());
                    ---
                    Ãƒâ€šÃ‚Â
                    I could know that my test servlet is served well.
                    Ãƒâ€šÃ‚Â
                    Could you please review this?
                    Ãƒâ€šÃ‚Â
                    Ãƒâ€šÃ‚Â
                    And I saw another strange code. This is trivial.
                    Ãƒâ€šÃ‚Â
                    In GrizzlyWebServerDeployer.java
                    ---
                    public String appendWarContentToClassPath(String appliPath) throw ... {
                    Ãƒâ€šÃ‚ Ã‚ ...
                    Ãƒâ€šÃ‚ Ã‚ if (appliPath != null && appliPath.endsWith(File.pathSeparator)) {
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â appliPath = appliPath + File.pathSeparator;
                    Ãƒâ€šÃ‚ Ã‚ }
                    }
                    ---ÂÂÂ
                    File.pathSeparator is equal to ";" in Windows.
                    Ãƒâ€šÃ‚Â
                    Perhaps you mean File.separator "/" or "\". Is it right?
                    Ãƒâ€šÃ‚Â
                    Then, the proposed patch is here.
                    ---
                    public String appendWarContentToClassPath(String appliPath) throw ... {
                    Ãƒâ€šÃ‚ Ã‚ ...
                    Ãƒâ€šÃ‚ Ã‚ if (appliPath != null && !appliPath.endsWith(File.separator)) {
                    Ãƒâ€šÃ‚ Ã‚ Â Â Â appliPath = appliPath + File.separator;
                    Ãƒâ€šÃ‚ Ã‚ }
                    }
                    ---ÂÂÂ
                    Ãƒâ€šÃ‚Â
                    Is also Right? But, I am not sure. :)
                    Ãƒâ€šÃ‚Â
                    Thanks!
                    Ãƒâ€šÃ‚Â
                    --
                    Bongjae Chang







        ---------------------------------------------------------------------
        To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
        For additional commands, e-mail: dev-help_at_grizzly.dev.java.net