Jump to content
Changes to the Jaspersoft community edition download ×

JRLoader problem-Excel XLS report generation


2005 IR Help

Recommended Posts

By: humairm - exwhyz

JRLoader problem-Excel XLS report generation

2004-05-07 09:21

The following line in my code throws a ClassCaseException with not much details:

 

JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(reportFile);

 

1. reportFile is a successfully compiled *.jasper file and works perfectly fine when generated as PDF

2. There is no incorrect class casting inside the XML report template. I even removed everything from the body of the <jasperReport> element and saw that I got the same error.

 

Any help will be appreciated.

 

 

 

 

By: Chuck Deal - cdeal

RE: JRLoader problem-Excel XLS report generation

2004-05-07 09:30

Try JasperDesign instead of JasperPrint

 

 

 

 

By: humairm - exwhyz

RE: JRLoader problem-Excel XLS report generation

2004-05-07 09:37

JasperDesign jasperDesign = (JasperDesign)JRLoader.loadObject(reportFile);

 

I tried the above but I get the exact same problem.

 

 

 

 

By: Chuck Deal - cdeal

RE: JRLoader problem-Excel XLS report generation

2004-05-07 09:48

Ok, then.. What does reportFile represent? What type of object, what value?

 

 

 

 

By: humairm - exwhyz

RE: JRLoader problem-Excel XLS report generation

2004-05-07 09:54

reportFile is a java.io.File object and has been compiled using:

 

JasperCompileManager.compileReportToFile(context.getRealPath("/reports/Report.xml"), context.getRealPath("/reports/Report.jasper"));

 

Then I get a successful handle to the destination file using:

 

File reportFile = new File(context.getRealPath("/reports/Report.jasper"));

 

The above reportFile object is passed as an arg. to the JRLoader.loadObject which when cast either to JasperPrint or JasperDesign throws the class cast exception.

 

 

 

 

By: Chuck Deal - cdeal

RE: JRLoader problem-Excel XLS report generation

2004-05-07 10:24

What version of JasperReports? Can you post the Stack trace?

 

Man, I'm trying to help, but it doesn't look like anything in JRLoader is even being cast. I would assume that other people are using JRLoader to do the same thing it it obviously works for them....

 

The stack trace might help us find them fault point. Have you tried using a debugger and stepping through the point where the Exception occurs to see what the state of the variables are?

 

 

 

 

By: humairm - exwhyz

RE: JRLoader problem-Excel XLS report generation

2004-05-07 10:35

thankx for your persistence,

 

The error occurs the moment I cast the return value of JRLoader.loadObject(reportFile) to JasperDesign or JasperPrint. I put some comments in the code and it does not error out if I simply load the object.

 

Error occurs here:

JasperDesign jasperDesign = (JasperDesign)JRLoader.loadObject(reportFile);

 

If I replace the above with:

JRLoader.loadObject(reportFile);

 

I don't see any errors and that is making me think something with the casting is causing the problem.

 

___________________________________________

Here is the XML file:

 

<jasperReport

name="Report"

pageWidth="595"

pageHeight="842"

columnWidth="515"

columnSpacing="0"

leftMargin="40"

rightMargin="40"

topMargin="50"

bottomMargin="50">

</jasperReport>

 

I have removed everything from the body and the PDF works but the XLS does not. So I can rule out any problems with my XML template.

___________________________________________

 

The JasperReports version is: JasperReports 0.5.2

 

___________________________________________

 

I have even tried the following code and ended up with the same problem:

 

 

___________________________________________

 

 

Here is the stack trace:

 

java.lang.ClassCastException

at dori.jasper.engine.JRAbstractExporter.setInput(JRAbstractExporter.java:177)

at dori.jasper.engine.export.JRXlsExporter.exportReport(JRXlsExporter.java:198)

at com.synovate.pilot.servlets.reports.XlsServlet.service(Unknown Source)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:228)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)

at java.lang.Thread.run(Thread.java:536)

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...