aspose file tools*
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
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: 14432
    
  23

What does your code look like?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Casting exception-Cannot cast xxx with string to yyyy