You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Thorbjoern Andersen <tr...@biobase.dk> on 2002/04/29 14:19:06 UTC
Beans constructed with BCEL makes html:option throw ClassCastException
in Struts 1.0.2
As mentioned on this list previously I have, with great labour, written
a class which generates beans on the fly using BCEL based on a
user-provided Property mapping field-named to field-types.
This now works well, but my first attempt on using these beans with
Struts have failed with the error message quoted at the end of this
message, which indicates to me that I have missed some part here.
I have an ArrayList of my beans, where this code works nicely:
{
java.util.ArrayList al =
abf.createBeanArrayList(stmt.executeQuery( "select distinct donor_ab0
from ab0_rules order by donor\
_ab0"));
pageContext.setAttribute( "bloodTypes", al);
java.util.ListIterator i = al.listIterator();
while( i.hasNext()) {
Object o = i.next();
out.println( o + " : " + BeanUtils.describe( o) + "<br>");
}
}
and prints out the following:
org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d@415727
: {donor_ab0=0, class=class
org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d}
org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d@c0fc8e
: {donor_ab0=A, class=class
org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d}
...
But when I want to use it with Struts 1.0.2 in the construct
...
<html:select property="bloodType">
<html:options collection="bloodTypes" property="donor_ab0"
labelProperty="donor_ab0"/>
</html:select>
...
it fails as described. If it is related, I have found that I can easily
cast the result of "bean.newInstance()" to an Object, but not to a
Class.
Any thoughts on how to fix this would be appreciated. I am so close to
making this work :-)
The error message is as follows
java.lang.IllegalArgumentException: java.lang.ClassCastException@4649ed
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.struts.util.PropertyUtils.getSimpleProperty(PropertyUtils.java:717)
at
org.apache.struts.util.PropertyUtils.getNestedProperty(PropertyUtils.java:426)
at org.apache.struts.util.PropertyUtils.getProperty(PropertyUtils.java:453)
at org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:202)
at _k__jsp._jspService(/k1/k.jsp:146)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:179)
at com.caucho.server.http.Invocation.service(Invocation.java:288)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)
at com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:937)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:536)
--
Thorbjoern Ravn Andersen
Scandiatransplant, c/o Christian Mondrup
89 49 53 01
http://biobase.dk/~tra
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Beans constructed with BCEL makes html:option throw ClassCastExceptionin
Struts 1.0.2
Posted by Thorbjoern Andersen <tr...@biobase.dk>.
James Mitchell wrote:
> With all the features of Struts 1.1 and 1.1-beta, why do you continue in
> this direction?
>
> Am I missing something?
>
> I can create a 5 page wizard and never write a single line of ActionForm
> code.
>
> Help me if I am misunderstanding.
I got around the symptoms so now it works by having a static ClassLoader
instead of one per instance. Beats me why.
I continue doing this since I do not need this for creating the actual
form-beans (for which it would be less useful), but for providing a
glue-layer between the databases we use, and the various presentation
utilities that expect beans, like struts and the display taglib. This
glue-layer should accept any ResultSet and allow access to the
individual fields, which my solution do reasonably well.
If you know of such an OpenSource product, I would love to hear it. Am
I really the only one who needs this?
> P.S. Shouldn't this be asked in the bcel-user@jakarta.apache.org???
Most likely, except that it is rather low traffic. I just gathered that
the people who wrote the Struts bean manipulation utilities were more
likely to linger here.
My apologies for using the list for these questions, but I do not
currently have a colleague to discuss the matters with.
--
Thorbjoern Ravn Andersen
Scandiatransplant, c/o Christian Mondrup
89 49 53 01
http://biobase.dk/~tra
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Beans constructed with BCEL makes html:option throw ClassCastExceptionin Struts 1.0.2
Posted by James Mitchell <jm...@telocity.com>.
With all the features of Struts 1.1 and 1.1-beta, why do you continue in
this direction?
Am I missing something?
I can create a 5 page wizard and never write a single line of ActionForm
code.
Help me if I am misunderstanding.
JM
P.S. Shouldn't this be asked in the bcel-user@jakarta.apache.org???
> -----Original Message-----
> From: Thorbjoern Andersen [mailto:tra@biobase.dk]
> Sent: Monday, April 29, 2002 8:19 AM
> To: Struts Users Mailing List
> Subject: Beans constructed with BCEL makes html:option throw
> ClassCastExceptionin Struts 1.0.2
>
>
> As mentioned on this list previously I have, with great labour, written
> a class which generates beans on the fly using BCEL based on a
> user-provided Property mapping field-named to field-types.
>
> This now works well, but my first attempt on using these beans with
> Struts have failed with the error message quoted at the end of this
> message, which indicates to me that I have missed some part here.
>
> I have an ArrayList of my beans, where this code works nicely:
>
> {
> java.util.ArrayList al =
> abf.createBeanArrayList(stmt.executeQuery( "select distinct donor_ab0
> from ab0_rules order by donor\
> _ab0"));
> pageContext.setAttribute( "bloodTypes", al);
> java.util.ListIterator i = al.listIterator();
> while( i.hasNext()) {
> Object o = i.next();
> out.println( o + " : " + BeanUtils.describe( o) + "<br>");
> }
> }
>
> and prints out the following:
>
> org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d@415727
> : {donor_ab0=0, class=class
> org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d}
>
> org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d@c0fc8e
> : {donor_ab0=A, class=class
> org.scandiatransplant.anonybeans.Xcc416f1298d2f3e4.3e9584e0f1d96d}
> ...
>
> But when I want to use it with Struts 1.0.2 in the construct
>
> ...
> <html:select property="bloodType">
> <html:options collection="bloodTypes" property="donor_ab0"
> labelProperty="donor_ab0"/>
> </html:select>
> ...
>
> it fails as described. If it is related, I have found that I can easily
> cast the result of "bean.newInstance()" to an Object, but not to a
> Class.
>
> Any thoughts on how to fix this would be appreciated. I am so close to
> making this work :-)
>
>
>
>
> The error message is as follows
>
> java.lang.IllegalArgumentException: java.lang.ClassCastException@4649ed
> at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
> cessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at
> org.apache.struts.util.PropertyUtils.getSimpleProperty(PropertyUti
> ls.java:717)
> at
> org.apache.struts.util.PropertyUtils.getNestedProperty(PropertyUti
> ls.java:426)
> at
> org.apache.struts.util.PropertyUtils.getProperty(PropertyUtils.java:453)
> at
> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:202)
> at _k__jsp._jspService(/k1/k.jsp:146)
> at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
> at com.caucho.jsp.Page.subservice(Page.java:485)
> at
> com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:179)
> at com.caucho.server.http.Invocation.service(Invocation.java:288)
> at
> com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)
> at
> com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:937)
> at
> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
> at
> com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
> at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
> at java.lang.Thread.run(Thread.java:536)
>
>
>
>
> --
> Thorbjoern Ravn Andersen
> Scandiatransplant, c/o Christian Mondrup
> 89 49 53 01
> http://biobase.dk/~tra
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>