Jump to content
Changes to the Jaspersoft community edition download ×

Field Classes - ClassCastException non-String

2004 IR Help

Recommended Posts

By: keodark - keodark

Field Classes - ClassCastException non-String

2005-07-27 15:35


I am trying to pass a non-String class Object, through a field, to a report. I have specified the type of the field as Object, and then cast it to a java.util.Hashtable within the report - in a text field.


However, the cast to a Hashtable (which is definitely what the field is when I put it into my JRDataSource) throws a ClassCastException at fill time.


What's going on? -- Note that this Hashtable is NOT being used in place of the report's JRDataSource.. I'm experimenting with using the hashtable to make values available to the calling JRDataSource.






By: Teodor Danciu - teodord

RE: Field Classes - ClassCastException non-St

2005-07-28 05:34




You said you have put the Hashtable object into a text field.

But text field values are also typed. Make sure the value

you display in the text field is of the same type with

the text field type. In any case, text fields do not accept

Hashtable objects directly as values so there must be

a second cast in your expressions.


I hope this helps.







By: keodark - keodark

RE: Field Classes - ClassCastException non-St

2005-07-28 10:45

I figured out my own solution - it seems there's some sort of inner cast used on Fields, specifically... whenever I used Object as the Field type, any attempt on my part to cast it to its real type met with a ClassCastException.


However, placing the Hashtable into an Object-typed _Parameter_ worked just great, as I was able to cast it back to a Hashtable and use it just fine.


Thanks :)

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...