Hello,
I am using JasperServer comunity edition 5.0.0 and I am doing webservice call using jasperserver-ireport-plugin-4.2.0.jar in Java . All functionality and parameters works...except for JRParameter.REPORT_TIME_ZONE. My code structure looks like this:
parameters.put(JRParameter.REPORT_TIME_ZONE, TimeZone.getDefault()); //yes it is java.util.TimeZone and yes I tested multiple timezones
parameters.put(JRParameter.REPORT_LOCALE, reportLocale); //here I set locale and it works when I comment out adding REPORT_TIME_ZONE parameter
Map runReport = myJasperWebService.runReport(rd.getUriString(), parameters, serverParameters); //here I run report
And I am getting
java.lang.Exception: 1 - java.lang.String cannot be cast to java.util.TimeZone
at com.jaspersoft.jasperserver.irplugin.wsclient.WSClient.runReport(WSClient.java:382)
at main.MyJIClient.runReport(MyJIClient.java:96)
at main.Run.main(Run.java:64)
runReport method has only this...
ResourceDescriptor rd = new ResourceDescriptor();
rd.setWsType(ResourceDescriptor.TYPE_REPORTUNIT);
rd.setUriString(reportUri);
return server.getWSClient().runReport(rd, parameters, serverParameters);
Am I using it wrong, which I dont think so because every other parameter including Locale settings works nice and reports are created or is there possibly problem in implementation of ireport-plugin or JasperServer implementation?
Thanks for any advice or hint
3 Answers:
You are trying to set a string value to TimeZone variable amma.
If you want a TimeZone variable, check for TimeZone API and see how to pass string value to it.
hope that helps.
Hi, thanks again for answer however as I wrote in question...
parameters.put(JRParameter.REPORT_TIME_ZONE, TimeZone.getDefault()); //yes it is java.util.TimeZone and yes I tested multiple timezones
I am passing valid java.util.Timezone not any string and still I am getting this exception...that is the problem..by all manuals, tutorials and how-tos I am doing it in correct way and it is not working.
Ok made some more research, still same problem, but looks like server doesn't recognize sun.util.calendar.ZoneInfo as as java.util.TimeZone.
//adding timezone as parameter
parameters.put(JRParameter.REPORT_TIME_ZONE, TimeZone.getDefault() );
in debug mode in eclipse I see that parameter is defined as REPORT_TIME_ZONE=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
But this is default timezone definition in Java. Is there any workaround or anyone has idea how to solve this problem?
Hi, thansks a lot for answer. Report has set Default timezone however when run on JAsperServer I need to pass him timezoen as parameter, which should be done by setting parameter REPORT_TIME_ZONE because I need to specify in which timezone dates and time should be shown in generated report.
However when I pass this parameter I get
java.lang.Exception: 1 - java.lang.String cannot be cast to java.util.TimeZone
at com.jaspersoft.jasperserver.irplugin.wsclient.WSClient.runReport(WSClient.java:382)
at main.MyJIClient.runReport(MyJIClient.java:96)
at main.Run.main(Run.java:64)
I need to override the timezone but so far withotu success.