I'm learning ANT and I'm trying to deploy a web application in tomcat 6.0.20 server. I build the test application and I deploy it with the manager ant tasks and everything goes right. I load a HTML page and it works... When I try to view a JSP tomcat give me a JasperException, coused by a NullPointerException in the auto-generated Servlet. The JSP is almost an HTML file with jsp extension. The Exception is throwed in the _jspInit method when it tries to run the following: _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); somebody can help me? thanks!
Probably you have jsp-api-*.jar
in /WEB-INF/lib
. Remove it.
EDIT: Explanation
JSP API contains an abstract class JspFactory
. It has a static
field to store a server-specific JspFactory
implementation. So, Tomcat sets a value of this field and JSP page initialization code reads it to obtain a JspFactory
implementation. In your case you have two different JspFactory
classes - one loaded by server classloader from server jars and another loaded by application classloader from /WEB-INF/lib
. Because classes loaded by different classloaders are different classes, they have different static
field values, therefore JspFactory
obtained by the JSP code (_jspxFactory
) is null
.
This illustrates one of the possible problems caused by use of static
fields.