Jetty
  1. Jetty
  2. JETTY-1496

404 error page doesn't render layout template

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 7.6.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I've a Grails 2.0.1 application. I set up the following UrlMapping:

      "/"(controller:"home")
      "500"(view:'/error/serverError')
      "404"(view:'/error/notFound')

      This is my notFound.gsp page:

      <%@ page contentType="text/html;charset=UTF-8" %>
      <html>
      <head>
      <meta name="layout" content="main"/>
      <title>404 Not Found</title>
      </head>

      <body>
      <h2>Page not found</h2>
      <p>Back to <a href="$

      {createLink(uri:'/')}

      ">homepage</a></p>
      </body>
      </html>
      While developing (under Tomcat) the 404 error page renders correctly main layout template. But when I deploy the war in production under Jetty 7.6.2 and I browse to a non-existing url I get the 404 error page but without the main layout template.

      So it seems that Grails 2.0.1 doesn't play well with Jetty and the application can't render the template when a 404 error is hit. Under Tomcat works fine.

        Activity

        Hide
        Jan Bartel added a comment -

        Do you have a small example grails webapp that I can use to reproduce?

        Also, are there any errors in the jetty logs?

        thanks
        Jan

        Show
        Jan Bartel added a comment - Do you have a small example grails webapp that I can use to reproduce? Also, are there any errors in the jetty logs? thanks Jan
        Hide
        Jan Bartel added a comment -

        Thomas,

        Can you take a look at this issue?

        thanks
        Jan

        Show
        Jan Bartel added a comment - Thomas, Can you take a look at this issue? thanks Jan
        Hide
        Luca C. added a comment -

        Reproducing it's pretty easy. Just create a new grails app and edit the two files as in the bug description. These are the steps;

        1. grails create-app testapp
        2. vim conf/UrlMappings.groovy and add the following line: "404"(view:'/notFound')
        3. create grails-app/view/notFound.gsp page
        4. grails run-app

        at this point we're in development Tomcat and if I browse to http://localhost:8080/testapp/lklkj (non-existant url) I get the 404 error page rendered with the default grails template

        5. grails war

        Now I move the war to production running Jetty(7.6.2.v20120308), I browse to the same non-existant url and I get the 404 error page but without the default template.
        In start.log I see just this:

        2012-03-14 08:57:04.167:INFO:/:Initializing Spring FrameworkServlet 'grails-errorhandler'

        The sample application is 26 MB, where can I upload it ?

        Show
        Luca C. added a comment - Reproducing it's pretty easy. Just create a new grails app and edit the two files as in the bug description. These are the steps; 1. grails create-app testapp 2. vim conf/UrlMappings.groovy and add the following line: "404"(view:'/notFound') 3. create grails-app/view/notFound.gsp page 4. grails run-app at this point we're in development Tomcat and if I browse to http://localhost:8080/testapp/lklkj (non-existant url) I get the 404 error page rendered with the default grails template 5. grails war Now I move the war to production running Jetty(7.6.2.v20120308), I browse to the same non-existant url and I get the 404 error page but without the default template. In start.log I see just this: 2012-03-14 08:57:04.167:INFO:/:Initializing Spring FrameworkServlet 'grails-errorhandler' The sample application is 26 MB, where can I upload it ?
        Hide
        Thomas Becker added a comment -

        Yes, I will take care of it. I remember that this worked fine in a grails project I've been working on last year.

        @Luca: I will try to create the test app myself. If I'm having troubles I will get back to you to send me your sample app.

        Show
        Thomas Becker added a comment - Yes, I will take care of it. I remember that this worked fine in a grails project I've been working on last year. @Luca: I will try to create the test app myself. If I'm having troubles I will get back to you to send me your sample app.
        Hide
        Thomas Becker added a comment -

        I can confirm that the issue can be reproduced as described.

        grails precompiles the gsp files and puts them into the war's WEB-INF/classes directory. However when forwarded to an error page the template layout is not rendered in jetty. index.gsp works fine though.
        At the moment I can't tell if this is a jetty issue, a grails issue or grails using some tomcat specific servlet spec differences.

        I will dig a bit deeper on how grails' errorhandler works and how the templates are supposed to work.

        Show
        Thomas Becker added a comment - I can confirm that the issue can be reproduced as described. grails precompiles the gsp files and puts them into the war's WEB-INF/classes directory. However when forwarded to an error page the template layout is not rendered in jetty. index.gsp works fine though. At the moment I can't tell if this is a jetty issue, a grails issue or grails using some tomcat specific servlet spec differences. I will dig a bit deeper on how grails' errorhandler works and how the templates are supposed to work.
        Hide
        Thomas Becker added a comment -

        I've tried grails 1.3.7. The standard error.gsp doesn't contain a layout meta tag. So I've "cp error.gsp notFound.gsp" pasted the meta tag for the layout from index.gsp to notFound.gsp and...it works fine with grails 1.3.7.

        Show
        Thomas Becker added a comment - I've tried grails 1.3.7. The standard error.gsp doesn't contain a layout meta tag. So I've "cp error.gsp notFound.gsp" pasted the meta tag for the layout from index.gsp to notFound.gsp and...it works fine with grails 1.3.7.
        Hide
        Thomas Becker added a comment - - edited

        I can't see any misbehaviour within jetty and this is going quite deep into grails internals. So I raised this issue for now trying to get some help as I'm stuck:

        http://jira.grails.org/browse/GRAILS-8935

        Show
        Thomas Becker added a comment - - edited I can't see any misbehaviour within jetty and this is going quite deep into grails internals. So I raised this issue for now trying to get some help as I'm stuck: http://jira.grails.org/browse/GRAILS-8935
        Hide
        Luca C. added a comment -

        Thank you Thomas for your time spent in analysis. I should have opened this issue against grails. Anyway thanks. Luca

        Show
        Luca C. added a comment - Thank you Thomas for your time spent in analysis. I should have opened this issue against grails. Anyway thanks. Luca
        Hide
        Thomas Becker added a comment -

        Luca, you're welcome. However I'm not 100% certain yet that this is a grails issue. It just seems to me atm that it is, but as I'm not a grails expert I need support from the grails folks. Lets see what they come up with.

        Show
        Thomas Becker added a comment - Luca, you're welcome. However I'm not 100% certain yet that this is a grails issue. It just seems to me atm that it is, but as I'm not a grails expert I need support from the grails folks. Lets see what they come up with.
        Hide
        Thomas Becker added a comment -

        For the record here's the html generated:

        grails run-app
        <!doctype html>
        <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
        <!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
        <!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
        <!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
        <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"><!--<![endif]-->
        	<head>
        		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        		<title>Grails Runtime Exception</title>
        		<meta name="viewport" content="width=device-width, initial-scale=1.0">
        		<link rel="shortcut icon" href="/testapp/static/images/favicon.ico" type="image/x-icon">
        		<link rel="apple-touch-icon" href="/testapp/static/images/apple-touch-icon.png">
        		<link rel="apple-touch-icon" sizes="114x114" href="/testapp/static/images/apple-touch-icon-retina.png">
        		<link rel="stylesheet" href="/testapp/static/css/main.css" type="text/css">
        		<link rel="stylesheet" href="/testapp/static/css/mobile.css" type="text/css">
        		
        		
        		<meta name="layout" content="main">
        		<link rel="stylesheet" href="/testapp/static/css/errors.css" type="text/css">
        	
                
        	</head>
        	<body>
        		<div id="grailsLogo" role="banner"><a href="http://grails.org"><img src="/testapp/static/images/grails_logo.png" alt="Grails"/></a></div>
        		
            HUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
        		
        	
        		<div class="footer" role="contentinfo"></div>
        		<div id="spinner" class="spinner" style="display:none;">Loading&hellip;</div>
        		
                <script src="/testapp/static/js/application.js" type="text/javascript" ></script>
        
        	</body>
        </html>
        jetty
        <!doctype html>
        <html>
        	<head>
        		<title>Grails Runtime Exception</title>
        		<meta name="layout" content="main">
        		<link rel="stylesheet" href="/testapp-0.1/static/css/errors.css" type="text/css">
        	</head>
        	<body>
            HUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
        		
        	</body>
        </html>

        The same page in jetty is just not being decorated with the layout accordingly when it was a forward to an error page.

        Show
        Thomas Becker added a comment - For the record here's the html generated: grails run-app <!doctype html> <!--[ if lt IE 7 ]> <html lang= "en" class= "no-js ie6" > <![endif]--> <!--[ if IE 7 ]> <html lang= "en" class= "no-js ie7" > <![endif]--> <!--[ if IE 8 ]> <html lang= "en" class= "no-js ie8" > <![endif]--> <!--[ if IE 9 ]> <html lang= "en" class= "no-js ie9" > <![endif]--> <!--[ if (gt IE 9)|!(IE)]><!--> <html lang= "en" class= "no-js" ><!--<![endif]--> <head> <meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" > <meta http-equiv= "X-UA-Compatible" content= "IE=edge,chrome=1" > <title>Grails Runtime Exception</title> <meta name= "viewport" content= "width=device-width, initial-scale=1.0" > <link rel= "shortcut icon" href= "/testapp/ static /images/favicon.ico" type= "image/x-icon" > <link rel= "apple-touch-icon" href= "/testapp/ static /images/apple-touch-icon.png" > <link rel= "apple-touch-icon" sizes= "114x114" href= "/testapp/ static /images/apple-touch-icon-retina.png" > <link rel= "stylesheet" href= "/testapp/ static /css/main.css" type= "text/css" > <link rel= "stylesheet" href= "/testapp/ static /css/mobile.css" type= "text/css" > <meta name= "layout" content= "main" > <link rel= "stylesheet" href= "/testapp/ static /css/errors.css" type= "text/css" > </head> <body> <div id= "grailsLogo" role= "banner" ><a href= "http: //grails.org" ><img src= "/testapp/ static /images/grails_logo.png" alt= "Grails" /></a></div> HUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU <div class= "footer" role= "contentinfo" ></div> <div id= "spinner" class= "spinner" style= "display:none;" >Loading&hellip;</div> <script src= "/testapp/ static /js/application.js" type= "text/javascript" ></script> </body> </html> jetty <!doctype html> <html> <head> <title>Grails Runtime Exception</title> <meta name= "layout" content= "main" > <link rel= "stylesheet" href= "/testapp-0.1/ static /css/errors.css" type= "text/css" > </head> <body> HUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU </body> </html> The same page in jetty is just not being decorated with the layout accordingly when it was a forward to an error page.
        Hide
        Jan Bartel added a comment -

        This issue was moved to jetty eclipse bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=396568

        Show
        Jan Bartel added a comment - This issue was moved to jetty eclipse bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=396568
        Hide
        Luca C. added a comment -

        any news on the issue ?
        seems like I'm the only one using grails and jetty !!

        Show
        Luca C. added a comment - any news on the issue ? seems like I'm the only one using grails and jetty !!
        Hide
        Jan Bartel added a comment -

        Luca,

        The jetty project moved from Codehaus to Eclipse years ago and this jira instance is defunct. The new bug tracker is here: https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&product=Jetty&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED.

        In the comment on 14 Dec 2012 I posted a link to the copy of the issue I moved over to the new bug tracker. This is it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=396568

        As you can see, there was some change in Grails between version 1.3.7 and 2.0 that creates the problem, but the Grails folks have not followed up on the issue that Thomas opened with them: http://jira.grails.org/browse/GRAILS-8935

        I would suggest you try with the latest jetty/grails software, and if the issue persists, then post on the grails issue via the link above with the new information.

        cheers,
        Jan
        PS the mailing lists for jetty also moved, so you should post to jetty-users@eclipse.org if you want to interact with the jetty community at-large.

        Show
        Jan Bartel added a comment - Luca, The jetty project moved from Codehaus to Eclipse years ago and this jira instance is defunct. The new bug tracker is here: https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&product=Jetty&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED . In the comment on 14 Dec 2012 I posted a link to the copy of the issue I moved over to the new bug tracker. This is it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=396568 As you can see, there was some change in Grails between version 1.3.7 and 2.0 that creates the problem, but the Grails folks have not followed up on the issue that Thomas opened with them: http://jira.grails.org/browse/GRAILS-8935 I would suggest you try with the latest jetty/grails software, and if the issue persists, then post on the grails issue via the link above with the new information. cheers, Jan PS the mailing lists for jetty also moved, so you should post to jetty-users@eclipse.org if you want to interact with the jetty community at-large.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: