Re: One more problem with GAE + Sitemesh

[email protected]
Newsgroups gmane.comp.web.freemarker.user,gmane.comp.web.freemarker.devel
Message-ID <[email protected]>
Yeah, tried and it works.. I created a hello.jsp. After deploying the application, accessed hello.jsp before calling any other URL that would render ftl.
And yes, after that everything else works.. 

What could be the permanent solution of this ? May be this is a bug with jetty implementation on GAE.

 
    
Sudhir NimavatSenior software engineer. 
Quick start global PVT LTD.
Baroda - 390007
Gujarat, India
http://www.ramanandi.org
Warning: Spelling errors in this message are the product of a poor school system. Pay teachers more than  athletes..
  




________________________________
From: Attila Szegedi <[email protected]>
To: FreeMarker-devel <[email protected]>
Cc: freemarker <[email protected]>
Sent: Mon, 10 May, 2010 3:46:42 PM
Subject: Re: [FreeMarker-user] [Freemarker-devel] One more problem with GAE + Sitemesh

It looks like you're mixing JSP and FreeMarker with JSP taglibs in the same project. This would ordinarily be fine, but it's failing for you... The reason it ordinarily works fine is that FreeMarker will only install FreeMarkerJspFactory as a fallback JspFactory, provided for taglibs in case there's no other JspFactory implementation in the servlet container. The initialization code in FreeMarkerPageContext is this:


    static {
        if(JspFactory.getDefaultFactory() == null) {
            JspFactory.setDefaultFactory(new FreeMarkerJspFactory21());
        }
        logger.debug("Using JspFactory implementation class " + 
                JspFactory.getDefaultFactory().getClass().getName());
    }

This means that FreeMarkerJspFactory won't even get installed if there's another JspFactory already installed. I wonder why is Jetty not installing its own JspFactory for JSP pages. Can you try triggering Jetty into installing its own JspFactory first? Like, ensuring a JSP page is rendered before FreeMarker JSP support is being used? Would that solve the problem? If yes, we can think of how to move forward.

FWIW, the definition for the getPageContext() and releasePageContext are indeed this:

    public PageContext getPageContext(Servlet servlet, ServletRequest request, 
            ServletResponse response, String errorPageURL, 
            boolean needsSession, int bufferSize, boolean autoFlush) {
        // This is never meant to be called. JSP pages compiled to Java 
        // bytecode use this API, but in FreeMarker, we're running templates,
        // and not JSP pages precompiled to bytecode, therefore we have no use
        // for this API.
        throw new UnsupportedOperationException();
    }

    public void releasePageContext(PageContext ctx) {
        // This is never meant to be called. JSP pages compiled to Java 
        // bytecode use this API, but in FreeMarker, we're running templates,
        // and not JSP pages precompiled to bytecode, therefore we have no use
        // for this API.
        throw new UnsupportedOperationException();
    }

Note the comments explaining the reason for UnsupportedOperationException() -- these are never meant to be called from templates. 
Now, what's *really* strange is that your precompiled JSP page named "org.apache.jsp.WEB_002dINF.decorators.default_002ddecorator_jsp._jspService" is not calling getPageContext() first and getting an exception on that...

Attila.

On 2010.05.10., at 11:37, [email protected] wrote:

Found one more problem with GAE + sitemesh..
>
>I use sitemesh to decorate pages, the decorator is a jsp file..the pages which are being decorated are freemarker templates.. 
>it's fine because sitemash just care about the HTML.
>
>The setup runs fine on local environment.. where as when deployed to GAE it gives me this error..
>
>
>javax.servlet.ServletContext log: Unhandled exception occurred whilst decorating page
>java.lang.UnsupportedOperationException
>	at freemarker.ext.jsp.FreeMarkerJspFactory.releasePageContext(FreeMarkerJspFactory.java:41)
>	at org.apache.jsp.WEB_002dINF.decorators.default_002ddecorator_jsp._jspService(default_002ddecorator_jsp.java:99)
>	at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
>	at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
>	at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:192)
>	at com.opensymphony.sitemesh.compatability.OldDecorator2NewDecorator.render(OldDecorator2NewDecorator.java:46)
>	at com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(BaseWebAppDecorator.java:33)
>	at
> com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:84)
>	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>
>
> Seems that app engine is doing some thing strange with FreeMarkerJspFactory or reusing it in someway which isn't expected.
>
>   
>Sudhir NimavatSenior software engineer. 
>Quick start global PVT LTD.
>Baroda - 390007
>Gujarat, India
>http://www.ramanandi.org

------------------------------------------------------------------------------

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.