Tuesday, October 04, 2005

 
Error using Java 1.5 scriptlet in JSP

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 6 in the jsp file: /search.jsp
Generated servlet error:
The method setAttribute(String, Object) in the type ServletRequest is not applicable for the arguments (String, int)

An error occurred at line: 6 in the jsp file: /search.jsp
Generated servlet error:
The method setAttribute(String, Object) in the type ServletRequest is not applicable for the arguments (String, int)

An error occurred at line: 6 in the jsp file: /search.jsp
Generated servlet error:
The method setAttribute(String, Object) in the type ServletRequest is not applicable for the arguments (String, int)


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.foochal.servlet.filter.FoochalSessionFilter.doFilter(FoochalSessionFilter.java:25)
org.foochal.servlet.filter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:26)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

Comments:
Solution:
Add this to your TOMCAT_HOME/conf/web.xml
Solution:

<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>
org.apache.jasper.servlet.JspServlet
</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>

<!-- added to support java 1.5 scriptlets in tomcat 5.5 -->
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
 
One more step needs to be done.

Remove $catalina_homecommon/lib/jasper-compiler-jdt.jar, and copy ant.jar from the latest ant distribution to $cataline_home/common/lib.
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?