In the process of upgrading cr4je 11 to 12 version. Using crjava-runtime_12.2.218.jar inside my JavaEE Struts Application.
You would need to update your runtimes from the below link
http://scn.sap.com/docs/DOC-29757
Download 'SAP Crystal Reports for Java runtime components - Java Reporting Component (JRC) (~ 45 MB)'
Problem:
Managed to display the reports using ReportViewer jsp. However in the report with pagination, when I click next page an alert box showing this message.
The viewer is unable to connect with the CrystalReportViewerServlet that handles asynchronous requests. Please ensure that the Servlet and Servlet-Mapping have been properly declared in the application’s web.xml file
My ReportViewer jsp location:
Webcontent
+ crystalreportviewers
+ common
+ reports
- ReportViewer.jsp
Web.xml:
<context-param>
<param-name>crystal_document_view</param-name>
<param-value>weblayout</param-value>
</context-param>
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>MyWebApp/crystalreportviewers</param-value>
</context-param>
<context-param>
<param-name>crystal_image_use_relative</param-name>
<param-value>webapp</param-value>
</context-param>
<servlet>
<display-name>CrystalReportViewerServlet</display-name>
<servlet-name>CrystalReportViewerServlet</servlet-name>
<servlet-class>com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CrystalReportViewerServlet</servlet-name>
<url-pattern>/CrystalReportViewerHandler</url-pattern>
</servlet-mapping>
ReportViewer jsp:
<%@ page import = "com.crystaldecisions.report.web.viewer.*"%>
<%@ page import = "com.crystaldecisions.sdk.occa.report.data.*"%>
<%@ page import = "com.crystaldecisions.sdk.occa.report.data.*"%>
<%
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setName("Pending Report");
//Enable Active-X print mode.
viewer.setPrintMode(CrPrintMode.PDF);
//Obtain report source of the report that the viewer will display.
Object reportSource = session.getAttribute("pendingReport");
viewer.setReportSource(reportSource);
Fields fields = (Fields) session.getAttribute("fields");
viewer.setParameterFields(fields);
viewer.setHasLogo(false);
viewer.setOwnPage(true);
viewer.setDisplayGroupTree(false);
viewer.setEnableDrillDown(true);
viewer.setBestFitPage(true);
viewer.setURI("ReportActionClass.do?do=getPendingReport");
viewer.setHasToggleGroupTreeButton(false);
viewer.setHasViewList(false);
viewer.setReuseParameterValuesOnRefresh(true);
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
%>
Solution:
Problem get resolved if I move my report viewer jsp file to the same level as 'crystalreportviewers' folder and change context-param.
Report viewer location:
Webcontent
+ crystalreportviewers
- ReportViewer.jsp
web.xml context param:
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>
MyWebApp/crystalreportviewers</param-value>
</context-param>
Alternate method:
I was in a situation to find an alternate way because I don't have this issue in version 11. Moreover we have many reports at different folder levels.
So I've gone through the html source of created report viewer on both cases.(with problem & with solution)
If you check the generated source of crystal report viewer, you will find below code
Working condition (if crystal report viewer jsp is placed in the same level of \crystalreportviewers folder)
new bobj.crv.ViewerListener('AccountsPendingCallReport', new bobj.crv.ServletAdapter('CSAcctRewRpt.do?do=getPendingCallReport','CrystalReportViewerHandler'));
Otherwise you will see below (if crystal report viewer jsp is not placed in the same level of \crystalreportviewers folder)
new bobj.crv.ViewerListener('AccountsPendingCallReport', new bobj.crv.ServletAdapter('CSAcctRewRpt.do?do=getPendingCallReport','../../CrystalReportViewerHandler'));
The only difference is the second parameter of ServletAdapter constructor. Basically all user interactions (like navigation, export, download...) in crystal report are carried out by javascripts. So locate
allInOne.js in \crystalreportviewers folder and find the below snippet where bobj.crv.ServletAdapter object been invoked.
Here I've replaced 'servletUrl' with "CrystalReportViewerHandler".
before
bobj.crv.ServletAdapter=function(pageUrl,servletUrl){this._pageUrl=pageUrl;this._servletUrl=servletUrl;this._form=null;}
after
bobj.crv.ServletAdapter=function(pageUrl,servletUrl){this._pageUrl=pageUrl;this._servletUrl="CrystalReportViewerHandler";this._form=null;}
This will fix the issue. In this way you may not need to place your report viewer jsp at same level as '\crystalreportviewers' folder.