GAE/J: unable to register a custom ELResolver

I need to register a custom ELResolver for a Google App Engine project.

Since it must be registered before any request is received, as specified by the Javadoc:

It is illegal to register an ELResolver after the application has received any request from the client. If an attempt is made to register an ELResolver after that time, an IllegalStateException is thrown.

I'm using a ServletContextListener:

public class RegisterCustomELResolver implements ServletContextListener { 

    @Override 
    public void contextInitialized(ServletContextEvent sce) { 
        ServletContext context = sce.getServletContext(); 
        JspApplicationContext jspContext = 
            JspFactory.getDefaultFactory().getJspApplicationContext(context); 
        jspContext.addELResolver(new MyELResolver()); 
    } 

    ... 
}

The problem is that JspFactory.getDefaultFactory() returns always null. I've alreay filled a bug report. Any idea for a workaround?

Answers


I am not sure which servletcontainer GAE uses "under the hoods" (Jetty? Tomcat?), but this is recognizeable as a bug in Tomcat 6.x. A workaround is to force the loading of JspRuntimeContext yourself before getting the factory:

Class.forName("org.apache.jasper.compiler.JspRuntimeContext");

See if this or similar hack helps.


Need Your Help

How to use hbase with Spring Boot using Java instead of XML?

java spring spring-mvc hadoop spring-boot

I have Spring Boot Hadoop and want to take advantage of the Spring HbaseTemplate. My issue is the documentation has only information about the "xml" way of the configuration and setup.

How can I see only my interesting tags in Stack Overflow's list of questions?

support user-interface favorite-tags preferences

As you know, in your user preferences, you can hide ignored tags. This is good, but I don't want to put all the tags I am not interested in. Perhaps there are too many in total, or perhaps I am onl...