I got the same error. I did a little hacking around and determined that the
mystery object that crashes when it gets cast to a String is
TagData.REQUEST_TIME_VALUE
>From TagData.java:
/**
* Distinguished value for an attribute to indicate its value
* is a request-time expression which is not yet available because
* this TagData instance is being used at translation-time.
*/
public static final Object REQUEST_TIME_VALUE = new Object();
It seems this is a simple bug in struts. The offending line of code is
DefineTei.java:89
if (data.getAttributeString("value") != null)
It assumes the value in the attribute is a String which is not true when
the attribute is an expression.
The patch which i have tested on my computer is to do this instead
if (data.getAttribute("value") != null)
josh
On 2001.01.20 10:39:58 -0600 Incze Lajos wrote:
> Weird thing at <bean:define> (probably a tomcat error - I use
> tomcat 3.2.1 with the IBM jdk 1.3 on linux):
>
> Here is a sample JSP (copied from the "Bean User Guide"):
>
> ----------
> <%@page language="java" contentType="text/html;charset=ISO-8859-1"%>
>
> <%@ taglib uri='/WEB-INF/struts-bean.tld' prefix='bean' %>
>
> <bean:define id="last" scope="session" value='<%= request.getRequestURI()
> %>'/>
> <bean:write name="last" />
> ----------
>
> and here is the result:
>
> ----------
> Error: 500
>
> Location: /matademo/WEB-INF/jsp/main.jsp
>
> Internal Servlet Error:
>
> org.apache.jasper.JasperException: Unable to compile class for JSP
> at java.lang.Throwable.(Throwable.java:96)
> at java.lang.Exception.(Exception.java:44)
> at javax.servlet.ServletException.(ServletException.java)
> at org.apache.jasper.JasperException.(JasperException.java)
>
> ... etc. The relevant portion comes here:
>
> Root cause:
>
> java.lang.ClassCastException: java.lang.Object
> at javax.servlet.jsp.tagext.TagData.getAttributeString(TagData.java)
> at org.apache.struts.taglib.bean.DefineTei.getVariableInfo(DefineTei.java:89)
> at javax.servlet.jsp.tagext.TagInfo.getVariableInfo(TagInfo.java)
> ----------
>
> The offending code seems to be pretty innocent:
>
> // from org.apache.struts.taglib.bean.DefineTei.java:
>
> public VariableInfo[] getVariableInfo(TagData data) {
>
> String type = data.getAttributeString("type");
> if (type == null) {
> if (data.getAttributeString("value") != null) //**** Line 89
> type = "java.lang.String";
> else
> type = "java.lang.Object";
> }
>
> ----------
>
> As a temporary measure I give type attribute at bean:define and it works.
>
> ----------
> <%@page language="java" contentType="text/html;charset=ISO-8859-1"%>
>
> <%@ taglib uri='/WEB-INF/struts-bean.tld' prefix='bean' %>
>
> <bean:define id="last" scope="session"
> type="java.lanf.String"
> value='<%= request.getRequestURI() %>'/>
> <bean:write name="last" />
> ----------
>
> =========================================================================
> OFF TOPIC:
>
> In tomcat 3.2.1 there are a couple of "showstopper" errors (e.g.
> getUserPrincipal().getName() overlives sessions and sticks to the
> first logged in user, I have illegal access exceptions if I want
> to prepare struts bean variable from request, e.g.
>
> <bean:page id="req" property="request" />
> <bean:write name="req" property="pathInfo" /> bombs with illegal access
> exception
>
> etc.)
> =========================================================================
>
> So, the question. Doea anybody experiance these things in other
> environments or these are simply Tomcat bugs (in this case I will
> report it there). (OFF TOPIC: does anybody know when do we have
> a next bug fix release of Tomcat. I'd like to use it, but it's
> almost impossible at the moment - Imean: too much workaround).
> know when will be a release o
>
> Tia incze
>