This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Groovy and the fly likes Casting exception-Cannot cast xxx with string to yyyy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Casting exception-Cannot cast xxx with string to yyyy" Watch "Casting exception-Cannot cast xxx with string to yyyy" New topic
Author

Casting exception-Cannot cast xxx with string to yyyy

sinsand singh
Greenhorn

Joined: Dec 21, 2009
Posts: 8
Hi,
I am currently getting a casting exception,
Cannot cast object 'net.sf.jasperreports.engine.data.JRMapArrayDataSource@1a63401' with class 'java.lang.String' to class 'java.util.List'

The language is groovy.
Here in this exception what does "with class 'java.lang.String' means.
What this exception is trying to say?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

What does your code look like?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
sinsand singh
Greenhorn

Joined: Dec 21, 2009
Posts: 8
my groovy code is
def rows = []
try {
rows = sql.rows(query.toString())
} catch (Exception e) {
log.error "Could not execute ${query} with params ${e.getMessage()}", e.printStackTrace()
}
new JRMapArrayDataSource(rows)

I am getting the data in rows as arraylist.
After that I am putting the data in parameter
like
params.putAt("subReportData",new JRMapArrayDataSource(positionService.getpositionResultsForInner(params)))

and in jrxml i have put
<parameter name="subReportData" class="net.sf.jasperreports.engine.data.JRMapArrayDataSource" isForPrompting="false"/>

Any idea how to pass any datasource to jasper in groovy, i have worked in java and done similar thing with JRMapCollectionDataSource and that was working
 
wood burning stoves
 
subject: Casting exception-Cannot cast xxx with string to yyyy
 
Similar Threads
cannot be cast to String error
Converting Date to String in java
model.getValueAt(1,2);
Reason for ClassCastException
Mock Exam doubt Generics