Showing posts with label crystalreport. Show all posts
Showing posts with label crystalreport. Show all posts

Thursday, February 5, 2015

The viewer is unable to connect with the CrystalReportViewerServlet that handles asynchronous requests...

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.



Friday, May 23, 2014

ReportSDKException: Unexpected error determining relative path---- Error code:-2147217395 Error code

com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Unexpected error determining relative path---- Error code:-2147217395 Error code name:serverProgrammingError
at com.businessobjects.reports.sdk.d.byte(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.void(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.connect(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.y.a(Unknown Source)

Cause:

For the JRC XI Release 1 and higher, the reportLocation tag value you'd place in CRConfig.xml is relative to the location of CrystalReportEngine.jar file. You'd get that error if the app can't walk up the path from the jar file location to where it expects to find the rpt files.

Solution:

Make sure you've placed CrystalReportEngine.jar & all aother supporting jars in applications WEB-INF/lib.

List of jar files in my lib folder:

commons-discovery.jar
commons-logging.jar
Concurrent.jar
corbaidl.jar
CRDB_JavaServer.ini
CRDBJavabeansServer.jar
CRDBJavaServer.jar
CRDBJavaServerCommon.jar
CRDBJDBCServer.jar
CRDBXMLExternal.jar
CRDBXMLServer.jar
crlov.jar
crlovexternal.jar
crlovmanifest.jar
CrystalCharting.jar
CrystalCommon.jar
CrystalContentModels.jar
CrystalDatabaseConnectors.jar
CrystalExporters.jar
CrystalExportingBase.jar
CrystalFormulas.jar
CrystalQueryEngine.jar
CrystalReportEngine.jar
CrystalReportingCommon.jar
ebus405.jar
freessl201.jar
icu4j.jar
jaxrpc.jar
jrcerom.jar
jsafe.jar
keycodeDecoder.jar
log4j.jar
mergeboar.jar
MetafileRenderer.jar
pullparser.jar
rasapp.jar
rascore.jar
rpoifs.jar
saaj.jar
serialization.jar
sslj.jar
u211java.jar
URIUtil.jar
webreporting.jar
webreporting-jsf.jar
wsdl4j.jar
xbean.jar
xercesImpl.jar
xml-apis.jar
asn1.jar
axis.jar
axis-ant.jar
cecore.jar
celib.jar
ceplugins.jar
cereports.jar
certj.jar
cesession.jar
ceutils.jar
cexsd.jar
clientSDKOptions.xml