Grails
  1. Grails
  2. GRAILS-8935

Rendering of error pages doesn't work in jetty

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: URL mappings
    • Labels:
      None
    • Testcase included:
      yes

      Description

      Hi all,

      we've a couple of reports now that rendering gsp error pages using a layout like: <meta name="layout" content="main"> does not render the layout when a grails war is run in jetty.

      This report describes how to reproduce: https://jira.codehaus.org/browse/JETTY-1496

      The same thing works fine with grails run-app and thus in tomcat so I expected this to be a jetty issue and I've started some investigation. However as grails precompiles the view gsps and puts them into the war I quite don't get why error pages are missing the layout in jetty and not in tomcat. index.gsp however does work fine and gets the layout rendered properly.

      The same thing works fine with jetty using grails 1.3.7. So something must have been changed between 1.3.x and 2.0.x that affected this behaviour. Can you give me some insights about what has been changed in terms of URL mapping, grails-errorhandler servlet and layout rendering between those versions that might have caused this behaviour? Are you using some tomcat specific functionality which is not covered by the servlet spec or do you think that jetty is not according to the spec in a proper way.

      Jetty is not reporting any errors and it looks fine. However here's the debug output for the whole request:

      jetty debug output
      2012-03-21 12:41:14.494:DBUG:oejh.HttpParser:oejh.HttpParser#parseNext(HttpParser.java:277):filled 567/567
      2012-03-21 12:41:14.495:DBUG:oejs.Server:oejs.Server#handle(Server.java:344):REQUEST /testapp-0.1/asdfasdf on AsyncHttpConnection@71884b88,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=240,c=0},r=3
      2012-03-21 12:41:14.495:DBUG:oejsh.ContextHandler:oejsh.ContextHandler#doScope(ContextHandler.java:887):scope null||/testapp-0.1/asdfasdf @ o.e.j.w.WebAppContext{/testapp-0.1,file:/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/work/jetty-0.0.0.0-8080-testapp-0.1.war-_testapp-0.1-any-/webapp/},/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/webapps/testapp-0.1.war
      2012-03-21 12:41:14.495:DBUG:oejsh.ContextHandler:oejsh.ContextHandler#doScope(ContextHandler.java:959):context=/testapp-0.1||/asdfasdf @ o.e.j.w.WebAppContext{/testapp-0.1,file:/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/work/jetty-0.0.0.0-8080-testapp-0.1.war-_testapp-0.1-any-/webapp/},/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/webapps/testapp-0.1.war
      2012-03-21 12:41:14.495:DBUG:oejs.session:oejss.SessionHandler#doScope(SessionHandler.java:180):sessionManager=org.eclipse.jetty.server.session.HashSessionManager@1f1ee981
      2012-03-21 12:41:14.496:DBUG:oejs.session:oejss.SessionHandler#doScope(SessionHandler.java:181):session=null
      2012-03-21 12:41:14.496:DBUG:oejs.ServletHandler:oejs.ServletHandler#doScope(ServletHandler.java:392):servlet /testapp-0.1|/asdfasdf|null -> default
      2012-03-21 12:41:14.496:DBUG:oejs.ServletHandler:oejs.ServletHandler#doHandle(ServletHandler.java:454):chain=charEncodingFilter->hiddenHttpMethod->grailsWebRequest->sitemesh->urlMapping->default
      2012-03-21 12:41:14.496:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter charEncodingFilter
      2012-03-21 12:41:14.496:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter hiddenHttpMethod
      2012-03-21 12:41:14.496:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter grailsWebRequest
      2012-03-21 12:41:14.497:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter sitemesh
      2012-03-21 12:41:14.497:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter urlMapping
      2012-03-21 12:41:14.498:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1359):call servlet default
      2012-03-21 12:41:14.499:DBUG:oejs.DefaultServlet:oejs.DefaultServlet#getResource(DefaultServlet.java:372):Resource /asdfasdf.gz=null
      2012-03-21 12:41:14.499:DBUG:oejs.DefaultServlet:oejs.DefaultServlet#getResource(DefaultServlet.java:372):Resource /asdfasdf=null
      2012-03-21 12:41:14.499:DBUG:oejs.DefaultServlet:oejs.DefaultServlet#doGet(DefaultServlet.java:470):uri=/testapp-0.1/asdfasdf resource=null
      2012-03-21 12:41:14.499:DBUG:oejsh.ContextHandler:oejsh.ContextHandler#doScope(ContextHandler.java:887):scope /testapp-0.1||/testapp-0.1/grails-errorhandler @ o.e.j.w.WebAppContext{/testapp-0.1,file:/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/work/jetty-0.0.0.0-8080-testapp-0.1.war-_testapp-0.1-any-/webapp/},/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/webapps/testapp-0.1.war
      2012-03-21 12:41:14.500:DBUG:oejsh.ContextHandler:oejsh.ContextHandler#doScope(ContextHandler.java:959):context=/testapp-0.1||/grails-errorhandler @ o.e.j.w.WebAppContext{/testapp-0.1,file:/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/work/jetty-0.0.0.0-8080-testapp-0.1.war-_testapp-0.1-any-/webapp/},/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/webapps/testapp-0.1.war
      2012-03-21 12:41:14.500:DBUG:oejs.session:oejss.SessionHandler#doScope(SessionHandler.java:180):sessionManager=org.eclipse.jetty.server.session.HashSessionManager@1f1ee981
      2012-03-21 12:41:14.500:DBUG:oejs.session:oejss.SessionHandler#doScope(SessionHandler.java:181):session=null
      2012-03-21 12:41:14.500:DBUG:oejs.ServletHandler:oejs.ServletHandler#doScope(ServletHandler.java:392):servlet /testapp-0.1|/grails-errorhandler|null -> grails-errorhandler
      2012-03-21 12:41:14.500:DBUG:oejs.ServletHandler:oejs.ServletHandler#doHandle(ServletHandler.java:454):chain=grailsWebRequest->sitemesh->grails-errorhandler
      2012-03-21 12:41:14.500:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter grailsWebRequest
      2012-03-21 12:41:14.501:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter sitemesh
      2012-03-21 12:41:14.501:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1359):call servlet grails-errorhandler
      2012-03-21 12:41:14.506:DBUG:oejs.Server:oejs.Server#handle(Server.java:346):RESPONSE /testapp-0.1/asdfasdf  404
      2012-03-21 12:41:14.506:DBUG:oejs.AsyncHttpConnection:oejs.AsyncHttpConnection#reset(AsyncHttpConnection.java:206):Enabled read interest SCEP@2a1b7890{l(/0:0:0:0:0:0:0:1:53054)<->r(/0:0:0:0:0:0:0:1:8080),d=true,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=1r}-{AsyncHttpConnection@71884b88,g=HttpGenerator{s=4,h=0,b=0,c=-1},p=HttpParser{s=0,l=240,c=0},r=3}
      2012-03-21 12:41:14.507:DBUG:oejh.HttpParser:oejh.HttpParser#parseNext(HttpParser.java:277):filled 0/0
      2012-03-21 12:41:14.548:DBUG:oejh.HttpParser:oejh.HttpParser#parseNext(HttpParser.java:277):filled 588/588
      2012-03-21 12:41:14.549:DBUG:oejs.Server:oejs.Server#handle(Server.java:344):REQUEST /testapp-0.1/static/css/errors.css on AsyncHttpConnection@71884b88,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=240,c=0},r=4
      2012-03-21 12:41:14.549:DBUG:oejsh.ContextHandler:oejsh.ContextHandler#doScope(ContextHandler.java:887):scope null||/testapp-0.1/static/css/errors.css @ o.e.j.w.WebAppContext{/testapp-0.1,file:/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/work/jetty-0.0.0.0-8080-testapp-0.1.war-_testapp-0.1-any-/webapp/},/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/webapps/testapp-0.1.war
      2012-03-21 12:41:14.549:DBUG:oejsh.ContextHandler:oejsh.ContextHandler#doScope(ContextHandler.java:959):context=/testapp-0.1||/static/css/errors.css @ o.e.j.w.WebAppContext{/testapp-0.1,file:/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/work/jetty-0.0.0.0-8080-testapp-0.1.war-_testapp-0.1-any-/webapp/},/Users/tbecker/dev/jetty/jetty-distribution-7.6.2.v20120308/webapps/testapp-0.1.war
      2012-03-21 12:41:14.550:DBUG:oejs.session:oejss.SessionHandler#doScope(SessionHandler.java:180):sessionManager=org.eclipse.jetty.server.session.HashSessionManager@1f1ee981
      2012-03-21 12:41:14.550:DBUG:oejs.session:oejss.SessionHandler#doScope(SessionHandler.java:181):session=null
      2012-03-21 12:41:14.550:DBUG:oejs.ServletHandler:oejs.ServletHandler#doScope(ServletHandler.java:392):servlet /testapp-0.1|/static/css/errors.css|null -> default
      2012-03-21 12:41:14.550:DBUG:oejs.ServletHandler:oejs.ServletHandler#doHandle(ServletHandler.java:454):chain=charEncodingFilter->DeclaredResourcesPluginFilter->hiddenHttpMethod->grailsWebRequest->sitemesh->urlMapping->default
      2012-03-21 12:41:14.550:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter charEncodingFilter
      2012-03-21 12:41:14.550:DBUG:oejs.ServletHandler:oejs.ServletHandler$CachedChain#doFilter(ServletHandler.java:1328):call filter DeclaredResourcesPluginFilter
      2012-03-21 12:41:14.552:DBUG:oejs.Server:oejs.Server#handle(Server.java:346):RESPONSE /testapp-0.1/static/css/errors.css  200
      2012-03-21 12:41:14.552:DBUG:oejs.AsyncHttpConnection:oejs.AsyncHttpConnection#reset(AsyncHttpConnection.java:206):Enabled read interest SCEP@2a1b7890{l(/0:0:0:0:0:0:0:1:53054)<->r(/0:0:0:0:0:0:0:1:8080),d=true,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=1r}-{AsyncHttpConnection@71884b88,g=HttpGenerator{s=4,h=0,b=0,c=-1},p=HttpParser{s=0,l=240,c=0},r=4}
      2012-03-21 12:41:14.553:DBUG:oejh.HttpParser:oejh.HttpParser#parseNext(HttpParser.java:277):filled 0/0
      

      Cheers,
      Thomas

        Activity

        Show
        Graeme Rocher added a comment - Most likely cause is a change to ErrorHandlingServlet. The following changes have been made in Grails 2.0 since 1.3.7: https://github.com/grails/grails-core/commit/d13d3c3b1221225c77347cee9151bcaa05647ab8 https://github.com/grails/grails-core/commit/6366a81fc8ed581ceeadf581e018bf1c9d2c1d64 https://github.com/grails/grails-core/commit/7c66d07600a05d3628e301b5608505ea82a479b6 https://github.com/grails/grails-core/commit/d81027dd51303fbf8636934154dcd220e3fb370d https://github.com/grails/grails-core/commit/4cf8376d2fa1a2355240729be9b5614e16adde7c My guess is it would be a change in one the above commits
        Hide
        Thomas Becker added a comment - - edited

        Graeme, thanks for the fast reply. However as I'm not a grails expert at all it'll be great if you guys could have a first look at it.

        It would also be good to know on how the layout is being added at runtime. Are layouts being applied as some kind of servlet filter? If so, who decides when to apply a certain layout to a page. Could the way grails is forwarding to the error page affect the behaviour of the layout? I mean the same mechanism seems to work fine for index.gsp which is directly accessed.

        Any other ideas what might cause a different behaviour in tomcat compared to jetty?

        Show
        Thomas Becker added a comment - - edited Graeme, thanks for the fast reply. However as I'm not a grails expert at all it'll be great if you guys could have a first look at it. It would also be good to know on how the layout is being added at runtime. Are layouts being applied as some kind of servlet filter? If so, who decides when to apply a certain layout to a page. Could the way grails is forwarding to the error page affect the behaviour of the layout? I mean the same mechanism seems to work fine for index.gsp which is directly accessed. Any other ideas what might cause a different behaviour in tomcat compared to jetty?
        Hide
        Thomas Becker added a comment -

        Any update on this one? I've to admit that I got quite out of the topic.

        Show
        Thomas Becker added a comment - Any update on this one? I've to admit that I got quite out of the topic.

          People

          • Assignee:
            Unassigned
            Reporter:
            Thomas Becker
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development