Jump to content
We've recently updated our Privacy Statement, available here ×

Strange errors


2005 IR Help

Recommended Posts

By: Raj - purirb123

Strange errors

2004-07-27 12:48

I compiled my first jasper report in ireport and copied the compiled copy with rename extension as .jasper. I have following JSP to kick it off. Really I fill the report and want to show pdf. I get strange errors listed. What am I doing wrong. Seems from the documentation there is not much to do once .jasper file is created except having a small jsp as below.

 

Please guide me, I spent hours going thru samples given. Hope owner of this good product will put a real example of full application, we are trying to replace crystal report with this product but I spent almost one week learning this and still can not do this.

 

<%@ page errorPage="error.jsp" %>

<%@ page import="datasource.*" %>

<%@ page import="dori.jasper.engine.*" %>

<%@ page import="java.util.*" %>

<%@ page import="java.io.*" %>

<%@ page import="java.sql.*" %>

<%@ page import="dori.jasper.view.*" %>

 

 

<%

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

 

String URL="jdbc:oracle:thin:@153.61.2.116:1521:test";

String user="scott";

String pass="tiger";

Connection conn = null;

conn = DriverManager.getConnection (URL, user, pass);

File reportFile = new File(application.getRealPath("/reports/first.jasper"));

Map parameters = new HashMap();

parameters.put("my_par", "4");

 

JasperFillManager.fillReportToFile(reportFile.getPath(), parameters, conn);

JasperExportManager.exportReportToPdfFile(reportFile.getPath());

System.exit(0);

 

%>

 

 

 

------------> ERRORS

 

JasperReports encountered this error :

java.lang.ClassCastException

at dori.jasper.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:104)

at org.apache.jsp.jsp.run_005fjasper_jsp._jspService(run_005fjasper_jsp.java:75)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

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

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)

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

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

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

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

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

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

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

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

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

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

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

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

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

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

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

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

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

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

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

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

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

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

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

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

at java.lang.Thread.run(Unknown Source)

 

 

 

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-27 13:26

You might want to try

 

JasperPrint p = JasperFillManager(reportFile,parameters,conn);

JasperExportManager.exporToPdfStream(p,out);

 

to get the output from inside a jsp. It looks like you're trying to use the call that produces a String result, but there's nowhere for it to go.

 

 

 

 

 

 

By: Raj - purirb123

RE: Strange errors

2004-07-27 15:05

I still get errors. Here is my code now.:

 

<%@ page errorPage="error.jsp" %>

<%@ page import="datasource.*" %>

<%@ page import="dori.jasper.engine.*" %>

<%@ page import="java.util.*" %>

<%@ page import="java.io.*" %>

<%@ page import="java.sql.*" %>

<%@ page import="dori.jasper.view.*" %>

 

 

<%

 

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

// Define the connection to the database

String URL="jdbc:oracle:thin:@153.61.2.116:1521:test";

String user="test";

String pass="test";

Connection conn = null;

conn = DriverManager.getConnection (URL, user, pass);

File reportFile = new File(application.getRealPath("/reports/test.jasper"));

 

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

Map parameters = new HashMap();

parameters.put("t_title", "My sample report");

JasperPrint p = JasperFillManager.fillReport(jasperReport,parameters,conn);

JasperExportManager.exportToPdfStream(p,out);

 

 

 

System.exit(0);

 

%>

------------ ERRORS

 

Generated servlet error:

[javac] Compiling 1 source file

 

C:Program FilesApache Software FoundationTomcat 5.0workCatalinalocalhostjasper-webapporgapachejspjsprun_005fjasper_jsp.java:72: cannot resolve symbol

symbol : variable JRLoader

location: class org.apache.jsp.jsp.run_005fjasper_jsp

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

^

 

 

 

An error occurred at line: 84 in the jsp file: /jsp/run_jasper.jsp

 

Generated servlet error:

C:Program FilesApache Software FoundationTomcat 5.0workCatalinalocalhostjasper-webapporgapachejspjsprun_005fjasper_jsp.java:77: cannot resolve symbol

symbol : method exportToPdfStream (dori.jasper.engine.JasperPrint,javax.servlet.jsp.JspWriter)

location: class dori.jasper.engine.JasperExportManager

JasperExportManager.exportToPdfStream(p,out);

^

2 errors

 

 

 

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-27 15:26

JRLoader is in dori.jasper.engine.util

 

You didn't import it.

 

 

 

 

 

By: Raj - purirb123

RE: Strange errors

2004-07-27 16:07

Thanks. Now I get following error, why I have alreday imported above all classes needed. Thanks.

 

----------------------------------------

 

C:Program FilesApache Software FoundationTomcat 5.0workCatalinalocalhostjasper-webapporgapachejspjsprun_005fjasper_jsp.java:83: cannot resolve symbol

symbol : method exportToPdfStream (dori.jasper.engine.JasperPrint,javax.servlet.jsp.JspWriter)

location: class dori.jasper.engine.JasperExportManager

JasperExportManager.exportToPdfStream(p, out);

^

1 error

 

 

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-27 16:16

Are the pertinent jars in the WEB-INF/lib directory for your web application?

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-27 16:20

Also, you must have all the itext libraries available to do PDF work.

 

 

 

 

By: Raj - purirb123

RE: Strange errors

2004-07-27 17:38

Actually I am using sample web application. All I did was created my JSP and my own jasper file. I used war to deploy per sample application. That seems to work fine, however calling my jsp is giving these errors. I think all components are in place as sample web application works fine. I do see that one of the samples does use JasperExportManager so I will think all classes needed must have been wrapped by war correctly.

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-27 19:12

Sorry. I made a mistake. I told you to use out, which is a Writer, but what you need is the OutputStream.

You need to get the outputstream from the response

Like this (shamelessly stolen and modified code from

http://www.rgagnon.com/javadetails/java-0366.html }

 

 

<%@ page import="java.io.*" %>

// IMPORT ALL THE JASPER STUFF HERE

<%@page contentType="application/pdf" %><%

 

// build the ( JasperPrint p ) here

OutputStream o = response.getOutputStream();

JasperExportManager.exportToPdf(p,out);

o.flush();

o.close();

return;

%>

 

 

I haven't tested this. I just did a google search on the web. Good luck.

 

 

 

 

 

By: Raj - purirb123

RE: Strange errors

2004-07-28 07:45

We give up on this tool. Too little documentation. Thanks for your help.

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-28 08:11

Welcome to Open Source Software.

 

-----------------------------------------

http://sourceforge.net/forum/forum.php?thread_id=1117740&forum_id=113530

 

 

 

 

By: Raj - purirb123

RE: Strange errors

2004-07-28 08:57

Interesting reading. Well, I have still not given up. I am going to take a break and start fresh. It is kind of hard for those guys to work with these libraries who got used to working with point and clicks ...

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-07-28 09:05

I'm working on a .war distribution that does a simple report, seperate from the demo. I'll add you to the list when I get time to gather it together.

 

 

 

 

By: Raj - purirb123

RE: Strange errors

2004-08-06 05:18

Finally I had my servlet working, I pass on a compiled jasper report name and where clause. This runs like 10/15 reports we have in application. I was thinking Jasper report is a tool, really it is a package(s). My most errors were coming out of incorrect usage of java classes. Since we can use it we want to buy that pdf book on this site about it. Any preview available on that from buyers, does it have any examples etc.

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Strange errors

2004-08-06 13:58

I bought it, and it's useful although it's got some empty spots. Mostly I bought it to encourage Teodor.

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