Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Crystal Reports XI Prolem Post Reply Post New Topic
Author Message
mimo58
Newbie
Newbie


Joined: 13 Apr 2009
Location: Egypt
Online Status: Offline
Posts: 2
Quote mimo58 Replybullet Topic: Crystal Reports XI Prolem
     Posted: 13 Apr 2009 at 5:14am
HI all,

this is my first post here.

actually i'm facing a problem in Crystal reports XI and i've tried many solutions but it didn't work.

i'm using Crystal Reports XI R2 with JSP to view reports to the users.

i've created 3 JSPs to handle this.

1- Report_UI.jsp
2- ReportsURL_RAS.jsp
3- CrystalReportViewer_RAS.jsp


and here is the code for these 3 JSPs:
1- Report_UI.jsp:
    --------------------
the first part of this jsp contains the fields (serach criteria) entered bty user, then i included the
ReportsURL_RAS.jsp

<%@ page import = "com.ibm.vgj.uibean.VGDataElement" %>
<HTML><HEAD >
<jsp:useBean id="REPORT_UI" scope="request" class="my.pkg.REPORT_UIBean" />

<%
    VGDataElement EXT = REPORT_UI.getEXT();
    VGDataElement MESSAGE = REPORT_UI.getMESSAGE();
    VGDataElement SC12_ID = REPORT_UI.getSC12_ID();
    VGDataElement ID = REPORT_UI.getID();
    VGDataElement CODE = REPORT_UI.getCODE();
    VGDataElement MODEL = REPORT_UI.getMODEL();
    VGDataElement CNFG = REPORT_UI.getCNFG();
    VGDataElement TRNS_NUM = REPORT_UI.getTRNS_NUM();
    VGDataElement FRM_STR_CD = REPORT_UI.getFRM_STR_CD();
    VGDataElement TO_STR_CD = REPORT_UI.getTO_STR_CD();
    VGDataElement FRM_ITM_GRP_CD = REPORT_UI.getFRM_ITM_GRP_CD();
    VGDataElement TO_ITM_GRP_CD = REPORT_UI.getTO_ITM_GRP_CD();
    VGDataElement FRM_ORG_UNT_CD = REPORT_UI.getFRM_ORG_UNT_CD();
    VGDataElement TO_ORG_UNT_CD = REPORT_UI.getTO_ORG_UNT_CD();
    VGDataElement FRM_ITM_CD = REPORT_UI.getFRM_ITM_CD();
    VGDataElement TO_ITM_CD = REPORT_UI.getTO_ITM_CD();
    VGDataElement FRM_GDT = REPORT_UI.getFRM_GDT();
    VGDataElement TO_GDT = REPORT_UI.getTO_GDT();
    VGDataElement FRM_RGN_CD = REPORT_UI.getFRM_RGN_CD();
    VGDataElement TO_RGN_CD = REPORT_UI.getTO_RGN_CD();
    VGDataElement GRP_LVL = REPORT_UI.getGRP_LVL();
    VGDataElement REP_TYP = REPORT_UI.getREP_TYP();
    VGDataElement FRM_TRNS_GDT = REPORT_UI.getFRM_TRNS_GDT();
    VGDataElement TO_TRNS_GDT = REPORT_UI.getTO_TRNS_GDT();
    VGDataElement SC_TRNS_CLASS_FRM = REPORT_UI.getSC_TRNS_CLASS_FRM();
    VGDataElement SC_TRNS_CLASS_TO = REPORT_UI.getSC_TRNS_CLASS_TO();
    VGDataElement TRNS_TYP_CD_FRM = REPORT_UI.getTRNS_TYP_CD_FRM();
    VGDataElement TRNS_TYP_CD_TO = REPORT_UI.getTRNS_TYP_CD_TO();
    VGDataElement RPRT_GDT = REPORT_UI.getRPRT_GDT();
    VGDataElement RPRT_HDT = REPORT_UI.getRPRT_HDT();
    VGDataElement DEPT = REPORT_UI.getDEPT();
    VGDataElement RGN_NM = REPORT_UI.getRGN_NM();
    VGDataElement PRG_NM = REPORT_UI.getPRG_NM();
    VGDataElement SEC = REPORT_UI.getSEC();
    VGDataElement FRM_PO_DT = REPORT_UI.getFRM_PO_DT();
    VGDataElement TO_PO_DT = REPORT_UI.getTO_PO_DT();
    VGDataElement DOC_STATE = REPORT_UI.getDOC_STATE();
    VGDataElement BYR_CD = REPORT_UI.getBYR_CD();
    VGDataElement STR_CLSS = REPORT_UI.getSTR_CLSS();
    VGDataElement SPLR_CD = REPORT_UI.getSPLR_CD();
    VGDataElement FRM_SPLR_CD = REPORT_UI.getFRM_SPLR_CD();
    VGDataElement TO_SPLR_CD = REPORT_UI.getTO_SPLR_CD();
    VGDataElement FRM_CNTRCT_DT = REPORT_UI.getFRM_CNTRCT_DT();
    VGDataElement TO_CNTRCT_DT = REPORT_UI.getTO_CNTRCT_DT();
    VGDataElement WS_GN01_ID = REPORT_UI.getWS_GN01_ID();
    VGDataElement WS_SC17_ID = REPORT_UI.getWS_SC17_ID();
    VGDataElement WS_GN02_ID = REPORT_UI.getWS_GN02_ID();
    VGDataElement WS_USERID = REPORT_UI.getWS_USERID();
    VGDataElement WS_G_DT = REPORT_UI.getWS_G_DT();
    VGDataElement WS_H_DT = REPORT_UI.getWS_H_DT(); %>
<TITLE><%= REPORT_UI.getTitle() %></TITLE>

<%@ include file="ReportsURL_RAS.jsp"%>


</HEAD>

<BODY >


<FORM NAME="main" METHOD="POST" ACTION="<%= REPORT_UI.getGatewayURL() %>">


                            <!-- No comment defined for item SC12_ID -->
                            <INPUT TYPE=HIDDEN NAME="SC12_ID" VALUE="<%=    SC12_ID.getTextValue() %>">

/********** And so on for all other fields listed Above**************/

                       

           </FORM>


</BODY></HTML>





2- ReportsURL_RAS.jsp


<%@ page contentType="text/html%>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.application.*" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.data.*" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
<%@ page import="com.crystaldecisions.report.web.viewer.*" %>


<%

// Modify this path to the location of the report on your system.
String path = PRG_NM.getTextValue()+".rpt";

// Create a new Report Application Session.
ReportAppSession ra = new ReportAppSession();

// Create a RAS service.
ra.createService("com.crystaldecisions.sdk.occa.report.application.ReportClientDocument");

// Set the RAS server to be used for the service.
ra.setReportAppServer("HOCTFTSTAP1");

// Initialize RAS.
ra.initialize();

// Create the ReportClientDocument object.
ReportClientDocument clientDoc = new ReportClientDocument();

// Set the RAS server to be used.
clientDoc.setReportAppServer(ra.getReportAppServer() );

// Open the report, and set the open type to Read Only.
clientDoc.open(path, OpenReportOptions._openAsReadOnly);

//Set Database logon Information
clientDoc.getDatabaseController().logon("ctfdb2","ctfdb2");


//Set USER_ID report parameter
Fields parameterFields = clientDoc.getDataDefController().getDataDefinition().getParameterFields();
if (parameterFields.size() > 0 ){
ParameterFieldController paramController;
paramController = clientDoc.getDataDefController().getParameterFieldController();
paramController.setCurrentValue("", "user_id", WS_USERID.getTextValue());
}

// Store the ReportClientDocument in session to be retrieved by the Viewer jsp page
session.setAttribute("oClientDoc", clientDoc);

//Redirect to the Viewer page to keep processing seperate
response.sendRedirect("CrystalReportViewer_RAS.jsp");

%>





3- CrystalReportViewer_RAS.jsp

<%@ page contentType="text/html"%>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.application.*,
  com.crystaldecisions.sdk.occa.report.data.*,
  com.crystaldecisions.sdk.occa.report.lib.*,
  com.crystaldecisions.report.web.viewer.*"
%>
<%
/*=====================================================================
INSTANTIATE THE VIEWER AND DISPLAY THE REPORT THROUGH THE REPORT VIEWER
=======================================================================
    - Create a Viewer object
    - Set the source for the  viewer to the client documents report source
    - Process the http request to view the report
    - Dispose of the viewer object
*/
ReportClientDocument clientDoc =  (ReportClientDocument)session.getAttribute("oClientDoc");

// Create a Viewer object
CrystalReportViewer viewer = new CrystalReportViewer();
// Set the name for the viewer
viewer.setName("Crystal_Report_Viewer");
// Set the source for the  viewer to the client documents report source
viewer.setReportSource(clientDoc.getReportSource());

viewer.setPrintMode(CrPrintMode.PDF);

viewer.setHasRefreshButton(true);
viewer.setOwnPage(true);

// Process the http request to view the report
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);

// Release the memory used by the report
clientDoc.close();

%>



The Report is working OK, but if i click any button from the viewer bar sometimes it works and many times it gives the following exception:

Error page exception

Original Exception:
Error Message:
Error Code: 500
Target Servlet: /CrystalReportViewer_RAS.jsp
Error Stack:
java.lang.NullPointerException
     at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.d(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.getReportSource(Unknown Source)
     at com.ibm._jsp._CrystalReportViewer_5F_RAS._jspService(_CrystalReportViewer_5F_RAS.java:89)
     at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1096)
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
     at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
     at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
     at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:226)
     at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
     at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:748)
     at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
     at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
     at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
     at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
     at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
     at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
     at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
     at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
     at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
     at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)



i know that the problem is that the oClientDoc session variable is read as Null which caused this exception.


the question now.. HOW COULD I PREVENT THIS EXCEPTION FROM APPEARING??????????????

I NEED YOU HELP, AND SORRY FOR THIS VERY LONG POST  BUT I WANTED TO MAKE THE PROBLEM VERY CLEAR.

 
IP IP Logged
mimo58
Newbie
Newbie


Joined: 13 Apr 2009
Location: Egypt
Online Status: Offline
Posts: 2
Quote mimo58 Replybullet Posted: 13 Apr 2009 at 6:59am
I'm using Unmanaged RAS method and i already create physical folder and put all my reports in it.

reports are appearing well and everything is OK, but sometimes when i click Print,refresh or export button in the Crystal Reports Viewer bar it give me NullPoiinterException at these classes:

at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.d(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.getReportSource(Unknown Source)

which means that the Session variable of ReportClientDocument is read as Null in the CrystalReportViewer.jsp
IP IP Logged
pgoel
Newbie
Newbie


Joined: 29 May 2009
Online Status: Offline
Posts: 1
Quote pgoel Replybullet Posted: 29 May 2009 at 4:41pm

Get rid of the place where you close the clientDoc

 

I think its clientDoc.close();

 

You'll be fine.

IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum