I got the following error when I use getReportParameters in Publication. Error occurs at . What I try to do is to set parameters for IReport contained in Publication. Any help will be greatly appreciated.
The following code works in the server box version 3.1 but not works in the other server box version 4.0 .
Exception in thread "main" java.lang.NullPointerException: while trying to invoke the method com.crystaldecisions.sdk.occa.security.internal.ISecuritySession.getEffectivePreferredViewingLocale() of an object loaded from field com.crystaldecisions.sdk.plugin.desktop.report.internal.Report.m_session of an object loaded from local variable 'this'
at com.crystaldecisions.sdk.plugin.desktop.report.internal.Report.getPVL(Report.java:697)
at com.crystaldecisions.sdk.plugin.desktop.report.internal.Report.getReportParameters(Report.java:675)
at com.mpn.report.ReportService.setPublicationParameters(ReportService.java:368)
at com.mpn.report.ReportService.processRequest(ReportService.java:302)
at com.mpn.report.ReportService.run(ReportService.java:148)
at com.crystaldecisions.sdk.plugin.desktop.program.internal.ProgramWrapper.main(ProgramWrapper.java:174)
Here is my code:
// This routine will set publication parameter
protected void setPublicationParameters(IEnterpriseSession enterprisesession, IInfoStore infoStore, IInfoObject report,
String requestID, CallableStatement procGetParameter)
throws SDKException
{
try {
IPublication boPublication = (IPublication) report;
IProperties docProperties = report.getProcessingInfo().properties().getProperties("SI_PROCESSINFO_PER_DOC");
for (int num=1; num < docProperties.size(); num++) {
String numStr = Integer.toString( num );
IProperties oInfoDocumentProp = docProperties.getProperties(numStr);
IProperty prop = oInfoDocumentProp.getProperty("SI_NAME");
String report_name = (String) oInfoDocumentProp.getProperty("SI_NAME").getValue();
IInfoObjects boInfoObjects2=null;
IInfoObject boInfoObject2=null;
boInfoObjects2 = infoStore.query("Select SI_ID, SI_KIND, SI_PROCESSINFO FROM CI_INFOOBJECTS WHERE SI_NAME='" + report_name + "' AND SI_INSTANCE=0");
boInfoObject2 = (IInfoObject)boInfoObjects2.get(0);
int documentID = boInfoObject2.getID();
String documentKind = boInfoObject2.getKind();
IReport crystalReport = (IReport)enterprisesession.getPluginManager().getPluginInterface(CeKind.CRYSTAL_REPORT, IPluginMgr.Type.DESKTOP);
// Now retrieve any custom processing properties and add them into the infoobject
com.crystaldecisions.sdk.properties.IProperties processingProperties = boPublication.getDocumentProcessingInfo(documentID);
crystalReport.getProcessingInfo().properties().putAll(processingProperties);
// Now retrieve the processing info for the desired report.
IReportProcessingInfo boProcessingInfo = (IReportProcessingInfo)crystalReport;
// Now retrieve the report parameters collection
List boParamList = (List)boProcessingInfo.getReportParameters();
String parameterName;
String parameterValue;
// Now loop through the parameters and set values.
for (Iterator i = boParamList.iterator(); i.hasNext(); )
{
IReportParameter boParam = (IReportParameter)i.next();
parameterName = boParam.getParameterName();
procGetParameter.setString(1, requestID);
procGetParameter.setString(2, parameterName);
procGetParameter.executeQuery();
parameterValue = procGetParameter.getString(3);
IReportParameterValues boCurrentValues = boParam.getCurrentValues();
boCurrentValues.clear();
IReportParameterSingleValue boSingleValue = boCurrentValues.addSingleValue();
boSingleValue.setValue(parameterValue);
}
// Save everything back
boPublication.setDocumentProcessingInfo(documentID, documentKind, crystalReport.getProcessingInfo().properties());
}
// Save the publication
boPublication.save();
}
catch (SQLException ex) {
ex.printStackTrace();
}
catch (SDKException ex) {
ex.printStackTrace();
throw ex;
}
}