You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Scott Johnson <sc...@us.ibm.com> on 2006/10/04 23:48:36 UTC

[TC6] default JSP factory not initialized early enough

Rémy,

With the latest TC6 code, I'm seeing a problem that did not exist on 
earlier TC6 drivers.  Sorry that I can't put a finger on when this problem 
arose.  I looked into relevant source files (like JspRuntimeContext) but 
haven't found the source of the problem.

Here's the issue (a testcase is attached below).

My app is very simple: it installs ServletContextListener for the purpose 
of adding a custom ELResolver.  It accomplishes this via:

    public void contextInitialized(ServletContextEvent evt) {
        ServletContext context = evt.getServletContext();
        JspApplicationContext jspContext = 
JspFactory.getDefaultFactory().getJspApplicationContext(context);
        jspContext.addELResolver(new ChipsELResolver());
    }


The problem is that JspFactory.getDefaultFactory() is returning null 
(system.out in bold, below):

Oct 4, 2006 5:32:18 PM org.apache.catalina.core.AprLifecycleListener 
lifecycleEv
ent
INFO: The Apache Tomcat Native library which allows optimal performance in 
produ
ction environments was not found on the java.library.path: 
C:\javaFor6.0BuildJDK
15\java\jre\bin;.;C:\javaFor6.0BuildJDK15\java\bin;c:\mantis2.1\mantis\bin;C:\se
tupIBASE;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:
\Python22;C:\Program Files\PC-Doctor for 
Windows\services;c:\cvsnt-2.0.4;c:\ecli
pse;w:\;w:\bin;C:\Program 
Files\QuickTime\QTSystem\;C:\Diskeeper\;C:\CMVC\exe;C:
\CMVC\exe\bin;;C:\CMVCDC50;C:\CMVCDC50;C:\CMVCDC50;
Oct 4, 2006 5:32:18 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 4, 2006 5:32:19 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1234 ms
Oct 4, 2006 5:32:19 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 4, 2006 5:32:19 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.0-dev
Oct 4, 2006 5:32:19 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Oct 4, 2006 5:32:19 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive ELResolverTest.war
ChipsListener.contextInitialized  evt= 
javax.servlet.ServletContextEvent[source=
org.apache.catalina.core.ApplicationContextFacade@3fbe3fbe]
ChipsListener.contextInitialized  context= 
org.apache.catalina.core.ApplicationC
ontextFacade@3fbe3fbe
ChipsListener.contextInitialized  JspFactory.getDefaultFactory()= null
Oct 4, 2006 5:32:20 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Oct 4, 2006 5:32:20 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/ELResolverTest] startup failed due to previous errors
Oct 4, 2006 5:32:21 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 4, 2006 5:32:21 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Oct 4, 2006 5:32:21 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/63  config=null
Oct 4, 2006 5:32:21 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2657 ms


This is easily reproducible if you deploy the ELResolverTest.war before 
the server has started (I'm assuming JspFactory.setDefaultFactory() hasn't 
been invoked at the time the listeners are being installed).  If you 
deploy the WAR *after* the server starts, the problem does not manifest 
and the app works --- until you stop and restart the server.

This zip file contains the WAR in the ELResolverTest\dist directory; and 
the source and build scripts are provided as well.


Thanks!

-Scott