Bug 28986

Summary: ClassCastException in ImplicitObjects
Product: Taglibs Reporter: Trond Aasan <trond>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED INVALID    
Severity: major    
Priority: P3    
Version: 1.1   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Trond Aasan 2004-05-14 16:49:52 UTC
Using tomcat 5.0.24

This may belong to commons-el

Jasper uses the org.apache.commons.el implementation.

pageContext.getExpressionEvaluator() returns a
org.apache.commons.el.ExpressionEvaluatorImpl

From org.apache.commons.el.ImplicitObjects.java (which is the identical to
org.apache.taglibs.standard.lang.jstl.ImplicitObjects)

  static final String sAttributeName = 
    "org.apache.taglibs.standard.ImplicitObjects";


This line fails (ImplicitObjects.java:121)
  public static ImplicitObjects getImplicitObjects (PageContext pContext)
  {
    ImplicitObjects objs = 
      (ImplicitObjects)
      pContext.getAttribute (sAttributeName,
			     PageContext.PAGE_SCOPE);


Trying to cast org.apache.taglibs.standard.lang.jstl.ImplicitObjects to
org.apache.commons.el.ImplicitObjects

This means I can not use ExpressionEvaluators in my own taglibs.
Comment 1 Felipe Leme 2004-06-13 18:25:57 UTC
Hi Trond,

Could you give more details on how does it fails? Does it fail when you try to
use commons-el in your own tag handler? If so, could you please provide a simple
test case (i.e., a tag handler that tries to use commons-el and gets an exception)?

TIA,

Felipe
Comment 2 Trond Aasan 2004-06-14 17:30:54 UTC
Stacktrace

java.lang.ClassCastException
	org.apache.commons.el.ImplicitObjects.getImplicitObjects(ImplicitObjects.java:123)
	org.apache.commons.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:130)
	org.apache.jasper.runtime.PageContextImpl.resolveVariable(PageContextImpl.java:833)
	org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
	org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
	org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
	org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
	org.example.StoryTag.setStoryId(StoryTag.java:88)
	org.apache.jsp.edit.view_jspx._jspx_meth_model_story_0(view_jspx.java:263)
...
...

Offending method in StoryTag.java:

    public void setStoryId(String storyId) throws JspException {
	try {
	    Long value = (Long) pageContext.getExpressionEvaluator().evaluate(storyId,
Long.class, pageContext.getVariableResolver(), null);
	    this.storyId = value;
	} catch (ELException e) {
	    throw new JspException(e);
	}
    }

Clumsy coding (first attempt in trying to use EL in custom tags) :-)

This is a rather complex Struts application. I can't seem to create a simple
test case, but somewhere in the app the pageContext attribute
"org.apache.taglibs.standard.ImplicitObjects" is set to an instance of
org.apache.taglibs.standard.lang.jstl.ImplicitObjects and later retrieved (in
org.apache.commons.el.ImplicitObjects) as an
org.apache.commons.el.ImplicitObjects which causes the ClassCastException
Comment 3 Justyna Horwat 2004-06-17 16:57:27 UTC

*** This bug has been marked as a duplicate of 29402 ***
Comment 4 Mark Thomas 2008-07-28 05:55:01 UTC
Changed resolution to INVALID since duplicate bug has been deleted from Bugzilla and leaving as DUPLICATE creates referential integrity issues for the underlying database.