2010-03-31 2 views
2

Google App Engine 프로젝트에 사용자 정의 ELResolver을 등록해야합니다. 어떤 요청이 수신되기 전에 등록해야하기 때문에GAE/J : 사용자 정의 ELResolver를 등록 할 수 없습니다.

, 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.

은 내가 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()); 
    } 

    ... 
} 

문제는 JspFactory.getDefaultFactory() 반환 항상 null입니다. 나는 벌레 보고서를 채웠다. 해결 방법에 대한 아이디어가 있습니까?

답변

4

"under the hoods"(Jetty? Tomcat?)를 사용하는 servletcontainer GAE는 확실하지 않지만 Tomcat 6.x에서는 bug으로 인식 할 수 있습니다. 해결 방법은 공장을 받기 전에 JspRuntimeContext 자신의 로딩을 강제하는 것입니다 :이 식물 또는 유사한 해킹 도움이된다면

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

을 참조하십시오.

+0

좋다! 이제 java.lang.AbstractMethodError : javax.servlet.jsp.JspFactory.getJspApplicationContext (Ljavax/servlet/ServletContext;) Ljavax/servlet/jsp/JspApplicationContext; 예외가 발생했습니다. JSP 버전은 JSP 2.1을 위해 정의 된 2.0의 getApplicationContext()이다. 나는 확실히 운이 좋다. – dfa

+1

'ELResolver'는 JSP 2.1이다. GAE는 실제로 JSP 2.0입니까? JSP 2.1이 될 것으로 기대합니다. 'web.xml'이 Servlet 2.5로 선언 되었습니까? 여기 예제 : http://snipplr.com/view/3775/minimal-webxml-webapp-descriptor-version-25/ – BalusC

+0

2.5, 물론 :) – dfa

관련 문제