Mantis - Resin
Viewing Issue Advanced Details
5936 block always 08-17-15 17:21 09-24-15 14:07
libor  
ferg  
normal  
closed 4.0.45  
fixed  
none    
none 4.0.46  
0005936: JspTagSupport cannot be cast to javax.servlet.jsp.tagext.Tag
With upgrade to 4.0.45 many pages started failing with errors
XYZ cannot be cast to javax.servlet.jsp.tagext.Tag

I compared one of the failing fragments in generated by 4.0.40 with equivalent fragment compiled in 4.0.45

Fragment from 4.0.40, notice the use of TagAdapter:
    _jsp__xyz__tag_26 = new _jsp._WEB_22dINF._tags._xyz__tag();
    _jsp__xyz__tag_26.setJspContext(pageContext);
    _jsp__xyz__tag_26_adapter = new javax.servlet.jsp.tagext.TagAdapter(_jsp__xyz__tag_26);
    _jsp__xyz__tag_26.setActiveTest(_caucho_expr_2.evalString(_jsp_env));
    _jsp__xyz__tag_26.setJspBody(_jsp_fragment_0 = createFragment_0(null, _jsp_parentContext, pageContext, _jsp__xyz__tag_26_adapter, getJspBody(), _jsp_state, _jsp_pageManager));


Fragment from 4.0.45:
    _jsp__xyz__tag_26 = _jsp_state.get_jsp__xyz__tag_26();
    com.caucho.jsp.PageContextWrapper _jsp_context42
            = _jsp_pageManager.createPageContextWrapper(pageContext);
    _jsp_context42.setAttribute("activeTest", _caucho_expr_2.evalString(_jsp_env));
    _jsp__xyz__tag_26.setActiveTest(_caucho_expr_2.evalString(_jsp_env));
    _jsp__xyz__tag_26.setJspBody(_jsp_fragment_0 = createFragment_0(_jsp_fragment_0, _jsp_parentContext, pageContext, _jsp__xyz__tag_26, getJspBody(), _jsp_state, _jsp_pageManager));}

...

    private _jsp._WEB_22dINF._tags._xyz__tag _jsp__xyz__tag_26;

    final _jsp._WEB_22dINF._tags._xyz__tag get_jsp__xyz__tag_26() throws Throwable
    {
        if (_jsp__xyz__tag_26 == null) {
            _jsp__xyz__tag_26 = new _jsp._WEB_22dINF._tags._xyz__tag();
        }

        return _jsp__xyz__tag_26;
    }


In both cases the _jsp._WEB_22dINF._tags._xyz__tag extends com.caucho.jsp.java.JspTagSupport, in 4.0.45 it is not wrapped before the attempt to cast it as javax.servlet.jsp.tagext.Tag

I don't see a way we can work around this issue, thus it is blocking us from upgrading to 4.0.45


-----
A side note/question seems like the SimpleTag instances are now cached, but the documentation https://docs.oracle.com/javaee/5/api/javax/servlet/jsp/tagext/SimpleTag.html [^] states "Unlike classic tag handlers, simple tag handlers are never cached and reused by the JSP container." Is this going to cause problems???
 0005936.tar.bz2 [^] (363,006 bytes) 09-21-15 17:07

Notes
(0006651)
libor   
09-21-15 17:09   
The 0005936.tar.bz2 contains minimal failing app.

The key seems to be the scriptlet in a.tag, it can be empty, but need to be present to cause the CCE.

The nested tag need to extend TagSupport
(0006652)
nam   
09-22-15 07:56   
Thanks for the test case! We were able to easily reproduce it.

Resin 4.0.45 introduced a bug where it was looking for generated tag classes in the wrong directory (lower-cased, instead of what it was before). Because it couldn't find the classes, it fell back to a placeholder class, which was the cause for the exception. The bug only showed up for:

1. custom tag libraries
2. useBody

In reference to caching tags, the bug caused Resin to produce bad JSP code. Fixing the bug should produce JSP-spec compliant code (i.e. proper caching to tags).
(0006653)
ferg   
09-24-15 14:07   
jsp/1o41