Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » ClassCastException for JSP expression language(Cannot use jsp EL when running project with tomcat 7 (tomcat 6 ok))
ClassCastException for JSP expression language [message #754268] Tue, 01 November 2011 17:09 Go to next message
warhen  is currently offline warhen Friend
Messages: 4
Registered: November 2011
Junior Member
Hi, I am running the following version of eclipse:

Eclipse Java EE IDE for Web Developers.
Version: Indigo Service Release 1
Build id: 20110916-0149

I am seeing an issue that should be easy to reproduce because it happens after creating a new "Dynamic Web Project" without adding on any project natures or additional libraries.
All you need is to have the following two versions of tomcat installed:
- tomcat version 6 (I have 6.0.20)
- tomcat version 7 (I have 7.0.22)

Once the project is created, I put an index.jsp file in the "WebContent" directory.
The content of index.jsp is:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

${header["user-agent"]}


1) Run As --> Run on Server --> Tomcat v6.0 at localhost
Everything works (I get a webpage that shows what browser is being used).

2) Run As --> Run on Server --> Tomcat v7.0 at localhost
I get the following exception:

org.apache.jasper.JasperException: java.lang.ClassCastException: org.apache.jasper.runtime.ELContextImpl cannot be cast to org.apache.jasper.el.ELContextImpl
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:548)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:471)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.ClassCastException: org.apache.jasper.runtime.ELContextImpl cannot be cast to org.apache.jasper.el.ELContextImpl
	org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:982)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

I can find "org.apache.jasper.el.ELContextImpl" in the jasper.jar in the tomcat lib folder. However, I don't know where "org.apache.jasper.runtime.ELContextImpl" originates.
I have surfed the web a bit to find clues and the most I've been able to find is the notion that this sort of thing could be due to two separate class loaders clashing.

I can only guess at this point. All I know is that the simplest jsp page will work until you put any jsp expression in it, like ${myVar}.

It would be a relief if anyone has seen this or suspects where I messed up.

Thanks,

Warhen

[Updated on: Tue, 01 November 2011 17:10]

Report message to a moderator

Re: ClassCastException for JSP expression language [message #754409 is a reply to message #754268] Wed, 02 November 2011 13:12 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
It doesn't appear that org.apache.jasper.runtime.ELContextImpl would be
a normal part of Tomcat 6.0.x or 7.0.x. My only guesses as to where it
might be coming from is that you are using a packaged version of Tomcat
on Linux, instead of a binary archive from the Tomcat site. (Packagers
have been known to create Tomcat installs where not everything works.)
And second, it's sneaking into your project's "WEB-INF/lib" via some
jar. Check the "WEB-INF/lib" of your webapp under
"<workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp?/wtpwebapps"
(assuming a default WTP server configuration) and see if a jar there
contains this class. Such a jar shouldn't be there.

Cheers,
Larry

On 11/1/2011 1:09 PM, warhen wrote:
> Hi, I am running the following version of eclipse:
>
> Eclipse Java EE IDE for Web Developers.
> Version: Indigo Service Release 1
> Build id: 20110916-0149
>
> I am seeing an issue that should be easy to reproduce because it happens
> after creating a new "Dynamic Web Project" without adding on any project
> natures or additional libraries.
> All you need is to have the following two versions of tomcat installed:
> - tomcat version 6 (I have 6.0.20)
> - tomcat version 7 (I have 7.0.22)
>
> Once the project is created, I put an index.jsp file in the "WebContent"
> directory.
> The content of index.jsp is:
>
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
> pageEncoding="ISO-8859-1"%>
>
> ${header["user-agent"]}
>
> 1) Run As --> Run on Server --> Tomcat v6.0 at localhost
> Everything works (I get a webpage that shows what browser is being used).
>
> 2) Run As --> Run on Server --> Tomcat v7.0 at localhost
> I get the following exception:
>
> org.apache.jasper.JasperException: java.lang.ClassCastException:
> org.apache.jasper.runtime.ELContextImpl cannot be cast to
> org.apache.jasper.el.ELContextImpl
> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:548)
>
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:471)
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>
> root cause
>
> java.lang.ClassCastException: org.apache.jasper.runtime.ELContextImpl
> cannot be cast to org.apache.jasper.el.ELContextImpl
> org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:982)
>
> org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>
> I can find "org.apache.jasper.el.ELContextImpl" in the jasper.jar in the
> tomcat lib folder. However, I don't know where
> "org.apache.jasper.runtime.ELContextImpl" originates.
> I have surfed the web a bit to find clues and the most I've been able to
> find is the notion that this sort of thing could be due to two separate
> class loaders clashing.
>
> I can only guess at this point. All I know is that the simplest jsp page
> will work until you put any jsp expression in it, like ${myVar}.
>
> It would be a relief if anyone has seen this or suspects where I messed up.
>
> Thanks,
> Warhen
Re: ClassCastException for JSP expression language [message #754482 is a reply to message #754409] Wed, 02 November 2011 17:19 Go to previous messageGo to next message
warhen  is currently offline warhen Friend
Messages: 4
Registered: November 2011
Junior Member
Thanks for the reply Larry.

I am not using a packaged version of Tomcat.
Both v6 and v7 installs were obtained from tomcat.apache.org and installed before I installed eclipse. When I installed eclipse, I added them as servers.

I looked in the "<workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp?/wtpwebapps" directories as you suggested and found that there were no jars and not even a lib folder.
This is because the project I created had a single jsp file as its only feature. I added no libraries and it seems that no unknown functionality tried to add any either.

I decided to clean all projects and clean all of tomcat 7 and republish everything from scratch.
When I did this my project started working.
It's somewhat of a mystery as to why this worked because a thorough search did not turn up anything that cleaning would have solved by deletion.

Thanks for your help and if I figure out the cause of what happened, I will post it.

[Updated on: Wed, 02 November 2011 17:20]

Report message to a moderator

Re: ClassCastException for JSP expression language [message #754729 is a reply to message #754482] Fri, 04 November 2011 05:03 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Perhaps you can clarify, then, how v6 and v7 were installed?

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Re: Unable to see JSP variable contents in Eclipse Helios
Next Topic:Can the Formatter remove trailing whitespace in comments?
Goto Forum:
  


Current Time: Wed Apr 24 15:24:22 GMT 2024

Powered by FUDForum. Page generated in 0.02886 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top