File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Java Products and Servers and the fly likes Open crystal report in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "Open crystal report in JSP" Watch "Open crystal report in JSP" New topic
Author

Open crystal report in JSP

carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Hi i have a crystal report and want to open it using jsp file but i am getting errors though i added the jar files in classpath




here the error what i get is


org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 31 in the jsp file: /jrc_view_report.jsp
ReportClientDocument cannot be resolved to a type
28: try {
29:
30: //Open report.
31: ReportClientDocument reportClientDoc = new ReportClientDocument();
32: reportClientDoc.open(REPORT_NAME, 0);
33:
34: //Store the report source in session, will be used by the CrystalReportViewer.


An error occurred at line: 31 in the jsp file: /jrc_view_report.jsp
ReportClientDocument cannot be resolved to a type
28: try {
29:
30: //Open report.
31: ReportClientDocument reportClientDoc = new ReportClientDocument();
32: reportClientDoc.open(REPORT_NAME, 0);
33:
34: //Store the report source in session, will be used by the CrystalReportViewer.


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


i included the jar files in the Tomcat build path-->add external jars-->ReportViewer.jar,webreporting-core.jar,webreportingtags.jar,Concurrent.jar,CrystalReportEngine.jar

But still why am i getting this error can anybody help me out with this issue..
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

I could solve the issue by adding the jar files in the WEB-INF/lib folder --->
jrcerom.jar,log4j.jar,rasapp.jar,rascore.jar,ReportViewer.jar,Serialiazation.jar,webreporting-core.jar,CrystalReportEngine-confi.xml,CrystalReportEngine.jar


now the error changed to

com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Unable to locate CRConfig.xml configuration file---- Error code:-2147467259 Error code name:failed
at com.crystaldecisions.reports.reportengineinterface.a.a.b.a(Unknown Source)
at com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)
at org.apache.jsp.jrc_005fview_005freport_jsp._jspService(jrc_005fview_005freport_jsp.java:76)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi ruquia tabassum ,
You can directly call the crystal Report with following code(Tags) in your JSP

Before calling this jsp make sure that you have crytal-tags.tld in your classpath.
This is the way I have been using for calling the crystal Reports and so far it is working
without any errors.
Hope this might help you.


Thanks & Regards
Eshu Khare
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

i created a test.jsp using your code eshu and also i copied the crystal-tags-reportviewer.tld into WEB-INF/lib folder of my application but i am getting error

org.apache.jasper.JasperException: /test.jsp(3,0) Unable to load tag handler class "com.crystaldecisions.report.web.viewer.taglib.ViewerTag" for tag "crviewer:viewer"
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1329)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1578)
org.apache.jasper.compiler.Parser.parse(Parser.java:127)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


i modified the jsp as


carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

I added the webreportingtags.jar file and now the error has changed to

exception

org.apache.jasper.JasperException: com/crystaldecisions/reports/exportinterface/IPageRange
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

javax.servlet.ServletException: com/crystaldecisions/reports/exportinterface/IPageRange
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.test_jsp._jspService(test_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NoClassDefFoundError: com/crystaldecisions/reports/exportinterface/IPageRange
com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory.createReportSource(Unknown Source)
com.crystaldecisions.report.web.viewer.ReportAgentBase.case(Unknown Source)
com.crystaldecisions.report.web.viewer.ReportServerControl.getReportSource(Unknown Source)
com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.int(Unknown Source)
com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(Unknown Source)
org.apache.jsp.test_jsp._jspx_meth_crviewer_005fviewer_005f0(test_jsp.java:109)
org.apache.jsp.test_jsp._jspService(test_jsp.java:62)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.ClassNotFoundException: com.crystaldecisions.reports.exportinterface.IPageRange
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1363)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1209)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory.createReportSource(Unknown Source)
com.crystaldecisions.report.web.viewer.ReportAgentBase.case(Unknown Source)
com.crystaldecisions.report.web.viewer.ReportServerControl.getReportSource(Unknown Source)
com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.int(Unknown Source)
com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(Unknown Source)
org.apache.jsp.test_jsp._jspx_meth_crviewer_005fviewer_005f0(test_jsp.java:109)
org.apache.jsp.test_jsp._jspService(test_jsp.java:62)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Please help me out to solve this issue...

eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi,
this is the structure for crytal-tags-reportviewr.tld


Please paste crytal-tags-reportviewer.tld in your WEB-INF but not inside the lib also make sure you have the javaHelper Class for it, if dont below is the code for it please see as per to your application.

Please also make sure you have place the CRConfig.xml in you class path.
Then on I hope it shall work.
Hope this will help you in openning you report.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Hey Eshu thanks for replying anyhow i could solve the problem and my crystal report is opening with the jsp but the images to scroll next page,previous page, search for text stc are not displayed and there appears just a tooltip with 'X' can you suggest me how do i solve this issue.

eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi ruquia tabassum,
you can please check that toolbar and display tag in crystal-tags-reportviewr.tld are set true or false and likewise as per to your display need can set those tags true whichever you want to display and false whichever you don't want to display in your viewer jsp.
Also please let me know what was actually you were mistaking and then how you could resolve it.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

I was missing the jar files and i copied them in my WEB-INf/lib directory and then able to display the report and regarding the toolbar i copied the crystalreportviewers11 folder in my application root insted of the crystalreportviewers10 and now i could see the toolbar with option of print and export to pdf but now when i print the file or try exporting to PDF it gives me error

com.crystaldecisions.report.web.viewer.CrystalReportViewer
com.crystaldecisions.reports.a.a.(Ljava/util/Properties;)V


Also when the crystalreport has option Save Data With Report checked then i can display the data in the report else it gives me error

com.crystaldecisions.report.web.viewer.CrystalReportViewer
Error finding JNDI name (Xtreme Sample Database 11)

My reports will be dynamic and need not be saved with data ... you can suggest me if you came across such errors anytime.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

After all the errors i could solve the problem and now open a crystal report properly. I would like to specify the correct steps to follow:-
Note:here i am using Business Objects XI and Crystal Reports XI

1)inside the webapps create application root ----we suppose it to be "CrystalReport"
2)Copy some sample jsp file that calls the crystal report in the root folder.



3)Now create WEB-INF folder inside "CrystalReport" folder and also create a lib,classes folder inside WEB-INF

4)inside the web-inf/lib directory copy the jar files that comes along with your BusinessObjects and crystal report installation(C:\Program Files\Common Files\Business Objects\3.0\java\lib, C:\Program Files\Common Files\Business Objects\3.0\java\lib\external). Also copy .tld file in the WEB-INF/lib folder thats present at location C:\Program Files\Common Files\Business Objects\3.0\java\lib\taglib.

5)Copy folder crystalreportviewers11 into root directory.

6)create web.xml under WEB-INF directory and the file looks like


7)copy the .rpt file in WEB-INF directory, Put the CRConfig.xml,CrystalReportEngine-config.xml inside WEB-INF/classes folder and change the report location tag inside the CRConfig.xml,CrystalReportEngine-config.xml files as

<reportlocation>..</reportlocation>

8)Now restart TOmcat and call the Jsp as http://localhost:8080/CrystalReport/Sample.jsp.

If you get any errors you can mail me or post it here i hope that now after facing dozens of errors i could solve the problem.
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi ruquia tabassum ,

As much I know for JNDI error, I faced it few times when I tried to ran few sample downloaded reports.
But never while running the reports with my database.
I am working on struts using eclipse crystal plugin to run my report.
In struts with this plugin I don't need to mention the JNDI connection specification while
for other JRC you will have to mention the JNDI name otherwise it passes the error.

One thing I want to know from you that I have tried various ways to run a report with parameters
but when I integrate the report into my application only once it takes the parameter that is when running first time rest all
I have to set the parameter value from crystal report tool bar itself.
It is happening I am able to generate the report with data by passing the parameters but what I have been trying is to
invoke the parameter each time when-ever i run or open that report which is I am unble to do.
If you have any idea please let me know.
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi ruquia tabassum ,
I would also suggest you to use WebElement for crystal report.
Its brilliant have many functions and ready to use formulas and views
which you can directly use with drag and drop with what ever your requirement.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Eshu even i am new to crystal report whenever i come across your situation and found solution for that then i will surely post it here, right now i am trying to pass input parameters to report which runs a stored procedure and facing errors with it.
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi,
Reports with parameter I have worked on,
definitely can give a try to resolve the issue;
If you could provide some more details.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

OK, i am trying to call a report that invokes a stored procedure. i tried it this way but it gives me error





error

com.crystaldecisions.report.web.viewer.CrystalReportViewer
Unexpected Query Engine error


When i used "JPEReportSourceFactory" to open the report i did not get any error and the report opened the sample jsp is




Just want to know that ReportClientDoc doesnot work with the reports that calls a stored procedure? also how do i pass parameters to the report with JPEReportSourceFactory (searching examples).
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

How do i call a report that invokes stored procedure .. because here even if i use ReportClientDocument or JPEResourceFactory i am getting the error
Unexpected Query Engine Error... i even tried to fix the problem using the method provided at this link
http://www-01.ibm.com/support/docview.wss?uid=swg21206339 but still the error appears.
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
hi ruquia tabassum ,
For a query engine error there are two basic reason
1.Schema of the database is different from what the report was designed from.
2.The name of the table or some column from database is incorrect.
And in Rational Application using JNDI property
of a JDBC connection within the Crystal Report
throws a such error when run.
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
One more thing please also check field property of your report when integrating to the application if
designing with crystal report tool because in application config the data set is supposed to be
re-checked and correct.
This diffrence in dataset or database location also generate the
query engine error, error is absolutely coming from database property
I don't find it from coding aspect.
Also I would suggest you to download some relative plugin to
your application tool, things would be much simpler to work on.
Like I work on eclipse so eclipse has a crystal viewer plugin,
so some likewise.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Eshu thanks for your reply.. the crystal report is connected to database using DB2 native datasource and in my web.xml file i am giving the jndi connection as



I dont understand where am i going wrong ..
Also did you ever try calling a crystal report from jsp where crystal report calls stored procedure?
Benoit Greenhorns
Greenhorn

Joined: Jun 25, 2009
Posts: 3
Hello !

I'am trying to export a Crystal Report to PDF.
I have to pass a parameter to get the report.
This is the end of my SQL request in Crystal Report :

I tried to use this code :

Unfortunately it dosen't work
I got this message :

I think I am wrong when I pass the fieldname "numcredit".

Has someone an idea ?
Thanks for your help,

Benoit

Ps1 : I am using Crystal Report XI release 1
Ps2 : sorry for my english
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi ruquia tabassum ,

I call the report from jsp only.You can check the following tag : -

Hope this might help you.
Structrue for the crystal tag lib I have already posted to you.
eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
Hi Benoit ,
Have you set the config file in the class path.
Because if this not no report will open.
each report will generate the error "File Not Found".
Benoit Greenhorns
Greenhorn

Joined: Jun 25, 2009
Posts: 3
eshu khare wrote:Hi Benoit ,
Have you set the config file in the class path.
Because if this not no report will open.
each report will generate the error "File Not Found".


Hi eshu khare !

The classpath in CrConfig.xml ?
Yes I set it :



I think it is right, because I can export the report but without doing a request.


eshu khare
Ranch Hand

Joined: Aug 01, 2008
Posts: 44
I meant to place it in your WEB-INF folder.
Benoit Greenhorns
Greenhorn

Joined: Jun 25, 2009
Posts: 3
eshu khare wrote:I meant to place it in your WEB-INF folder.


It's done.

But I find the error.
I was wrong, I had to use setRecordSelectionFormula(String arg)

Now I have a conflict between the formula set in the report and the formula set with setRecordSelectionFormula(String arg).

Any idea ?
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

i just changed the rpt_cursor as in out variable in my stored procedure thats it .. now i am able to call the report from jsp.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open crystal report in JSP