cancel
Showing results for 
Search instead for 
Did you mean: 

JRC: NullPointerException

Former Member
0 Kudos

Hi,

I m using the report viewer to display report in my JSP page. The report will take in some parameters which the user have to enter. After entering the parameters and clicking enter, i get a "java.lang.NullPointerException". Please help. Is there any additional steps i should do after the user enter the prameter? If so, how should i get the parameter the user enter? Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I know that you do not want to hard code the values. But I have a sample code that set the parameters' values and export (in batch). It works very well and you can refer to it to sort out your issue.

Here it is below:

<%

/* Applies to: XI 
* Date Created: March 25 2008
* Description: This sample Creates a reportClientDocument Instance
* then in a serial way set parameters and  exports a report to PDF using the Java Reporting Component
* (JRC) SDK.  
* It uses the ReportExportControl to export without viewing
*  It is a batch process that set a parameter and export to pdf serially
* Author: Alphonse Kouassi
*/

// 

final String EXPORT_FILE0 = "myExportedReport1.pdf";
final String EXPORT_FILE1 = "myExportedReport2.pdf";
final String EXPORT_FILE2 = "myExportedReport3.pdf";
final String EXPORT_LOC = "C:\\";


%>

<%
//Use the relative path to the report; the physical or full qualified URL cannot
// be used.



String reportName = "Java_JRC_CR115_Export_With-Parameters-Batch/Java_JRC_CR115_Export_With-Parameters-Batch.rpt";

//Database credentials for the report's datasource.
final String USERNAME = "system";
final String PASSWORD = "mutcho";


	try
	{
		        //---------- Create a ReportClientDocument -------------
		        
		        ReportClientDocument oReportClientDocument = new ReportClientDocument();
		        
		        //---------- Set the path to the location of the report soruce -------------
		
		        //Open report.
		        oReportClientDocument.open(reportName, 0);
		        
	ParameterFieldController parameterFieldController = oReportClientDocument.getDataDefController().getParameterFieldController();
	
	// Set the logon credentials of the database in case you might be prompted to do so
	oReportClientDocument.getDatabaseController().logon(USERNAME, PASSWORD);
		        	
//=======================================================================================
//           FIRST PROCESS OF SETTING THE FIRST PARAMETER AND EXPORT 

//=======================================================================================		        
		        	
		        
		          	parameterFieldController.setCurrentValue("", "ID", new String ("1"));
		          	
		 
	//Export report and obtain an input stream that can be written to disk.
	//See the Java Reporting Component Developer's Guide for more information on the supported export format enumerations
	//possible with the JRC.
	ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)oReportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF);
			

	
	//These utility methods below demonstrate how to use the Java I/O libraries to write the input stream content
	//directly to the browser, or the server's file system.  Note: We are now working with APIs completely outside of
	//Crystal at this point:  						
	//Write file to disk...
	String EXPORT_OUTPUT = EXPORT_LOC + EXPORT_FILE0;
	out.println("Exporting to " + EXPORT_OUTPUT +"<br>");
	writeToFileSystem(byteArrayInputStream, EXPORT_OUTPUT);
	
//=======================================================================================
//           SECOND PROCESS OF SETTING THE SECOND PARAMETER AND EXPORT 

//=======================================================================================
//Check to ensure the report using the most current data scheme from its database
 oReportClientDocument.verifyDatabase();
	
	parameterFieldController.setCurrentValue("", "ID",new String ("2"));
	oReportClientDocument.getDatabaseController().logon(USERNAME, PASSWORD);
		 
	//Export report and obtain an input stream that can be written to disk.
	//See the Java Reporting Component Developer's Guide for more information on the supported export format enumerations
	//possible with the JRC.
 byteArrayInputStream = (ByteArrayInputStream)oReportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF);
			

	
	//These utility methods below demonstrate how to use the Java I/O libraries to write the input stream content
	//directly to the browser, or the server's file system.  Note: We are now working with APIs completely outside of
	//Crystal at this point:  						
	//Write file to disk...
    EXPORT_OUTPUT = EXPORT_LOC + EXPORT_FILE1;
	out.println("Exporting to " + EXPORT_OUTPUT +"<br>");
	writeToFileSystem(byteArrayInputStream, EXPORT_OUTPUT);
	
//=======================================================================================
//           THIRD PROCESS OF SETTING THE THIRD PARAMETER AND EXPORT 

//=======================================================================================
//Check to ensure the report using the most current data scheme from its database for updating the report

oReportClientDocument.verifyDatabase();

		parameterFieldController.setCurrentValue("", "ID", new String ("3"));
		 
	//Export report and obtain an input stream that can be written to disk.
	//See the Java Reporting Component Developer's Guide for more information on the supported export format enumerations
	//possible with the JRC.
 byteArrayInputStream = (ByteArrayInputStream)oReportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF);
			
	
	//These utility methods below demonstrate how to use the Java I/O libraries to write the input stream content
	//directly to the browser, or the server's file system.  Note: We are now working with APIs completely outside of
	//Crystal at this point:  						
	//Write file to disk...
    EXPORT_OUTPUT = EXPORT_LOC + EXPORT_FILE2;
	out.println("Exporting to " + EXPORT_OUTPUT +"<br>");
	writeToFileSystem(byteArrayInputStream, EXPORT_OUTPUT);
	//===========================================================================================
		          	
	//Release report.
    oReportClientDocument.close();
    
	
	}
	catch(ReportSDKException ex) 
	{	
		out.println(ex);
	}
    catch(Exception ex) 
	{
		out.println(ex);			
	}

%>




<%!
   /*
	* Utility method that demonstrates how to write an input stream to the server's local file system.  
	*/
	private void writeToFileSystem(ByteArrayInputStream byteArrayInputStream, String exportFile) throws Exception 
	{
	
		//Use the Java I/O libraries to write the exported content to the file system.
		byte byteArray[] = new byte[byteArrayInputStream.available()];

		//Create a new file that will contain the exported result.
		File file = new File(exportFile);
		FileOutputStream fileOutputStream = new FileOutputStream(file);

		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(byteArrayInputStream.available());
		int x = byteArrayInputStream.read(byteArray, 0, byteArrayInputStream.available());

		byteArrayOutputStream.write(byteArray, 0, x);
		byteArrayOutputStream.writeTo(fileOutputStream);

		//Close streams.
		byteArrayInputStream.close();
		byteArrayOutputStream.close();
		fileOutputStream.close();
		
	}
%>

Former Member
0 Kudos

Hi,

Thanks for ur sample code.

I can this error when i try to run: com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.NullPointerException---- Error code:-2147467259 Error code name:failed

Please help.

Former Member
0 Kudos

I managed to get a more detailed error. Please help.

ERROR - JRCAgent1 detected an exception: java.lang.NullPointerException

at sun.awt.FontConfiguration.getVersion(Unknown Source)

at sun.awt.FontConfiguration.readFontConfigFile(Unknown Source)

at sun.awt.FontConfiguration.<init>(Unknown Source)

at sun.awt.windows.WFontConfiguration.<init>(Unknown Source)

at sun.awt.Win32GraphicsEnvironment.createFontConfiguration(Unknown Sour

ce)

at sun.java2d.SunGraphicsEnvironment$2.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.java2d.SunGraphicsEnvironment.<init>(Unknown Source)

at sun.awt.Win32GraphicsEnvironment.<init>(Unknown Source)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou

rce)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Sour

ce)

at sun.font.FontManager.initSGEnv(Unknown Source)

at sun.font.FontManager.findFont2D(Unknown Source)

at java.awt.Font.getFont2D(Unknown Source)

at java.awt.Font.defaultLineMetrics(Unknown Source)

at java.awt.Font.getLineMetrics(Unknown Source)

at java.awt.font.TextMeasurer.initAll(Unknown Source)

at java.awt.font.TextMeasurer.<init>(Unknown Source)

at java.awt.font.LineBreakMeasurer.<init>(Unknown Source)

at java.awt.font.LineBreakMeasurer.<init>(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.ch.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.ch.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.a2.d

9(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.a2.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bi.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bt.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.be.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.be.g

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.be.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bt.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bf.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.b3.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bt.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.ca.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.a9.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.e.m.a(Unknown Source

)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.cd.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.b3.f

or(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.e.m.for(Unknown Sour

ce)

at com.crystaldecisions.reports.formatter.formatter.objectformatter.bt.a

(Unknown Source)

at com.crystaldecisions.reports.formatter.formatter.e.p.k(Unknown Source

)

at com.crystaldecisions.reports.formatter.formatter.e.p.az(Unknown Sourc

e)

at com.businessobjects.reports.sdk.b.i.byte(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unkno

wn Source)

at com.crystaldecisions.proxy.remoteagent.y.a(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.cf.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unkno

wn Source)

at com.crystaldecisions.sdk.occa.report.application.ReportSource.getPage

(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource

.getPage(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.NonDCPAdvancedReport

Source.getPage(Unknown Source)

at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.ge

tPage(Unknown Source)

at com.crystaldecisions.report.web.event.ac.a(Unknown Source)

at com.crystaldecisions.report.web.event.ac.a(Unknown Source)

at com.crystaldecisions.report.web.event.b2.a(Unknown Source)

at com.crystaldecisions.report.web.event.b7.broadcast(Unknown Source)

at com.crystaldecisions.report.web.event.av.a(Unknown Source)

at com.crystaldecisions.report.web.WorkflowController.do(Unknown Source)

at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknow

n Source)

at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)

at com.crystaldecisions.report.web.ServerControl.processHttpRequest(Unkn

own Source)

at com.crystaldecisions.report.web.viewer.taglib.ServerControlTag.doEndT

ag(Unknown Source)

at com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.

doEndTag(Unknown Source)

at org.apache.jsp.cr_jsp._jspx_meth_crviewer_005fviewer_005f0(cr_jsp.jav

a:124)

at org.apache.jsp.cr_jsp._jspService(cr_jsp.java:71)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper

.java:374)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3

37)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

alve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

alve.java:175)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

ava:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

ava:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

ve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

a:286)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

:844)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

ss(Http11Protocol.java:583)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44

7)

at java.lang.Thread.run(Unknown Source)

ted_ueda
Employee
Employee
0 Kudos

The NPE is being thrown by the Java JFC Font manager routine.

I would check that all fonts used in the report are TrueType, and present on the system where your Java Web Application Server is running.

I've also seen issues with corrupted TrueType font files.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi,

I have checked all the fonts i use are true type and it is not possible to be corrupted. They are also present in the system. But the same error still occur. Please advise.

ted_ueda
Employee
Employee
0 Kudos

How did you check the fonts?

How are you deploying the JSP files?

Are you mixing Java JDK and JVM versions?

What's happening is that the JRC is requesting a font, and the Sun Java AWT Font library is returing a NullPointerException. So I'd focus on the fonts and the JVM.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi,

Thanks for ur help. The problem is I have 2 JVM installed and they are using the wrong one. Now i am able to view the report.

My next major problem is how do i capture wat parameter value the user input?

Let say the user select report a.rpt to be view. The report viewer will prompt for user to enter the parameters required to generate this report. How do i capture wat the user have entered?

Please help. Thank you in advance.

ted_ueda
Employee
Employee
0 Kudos

I would close out this thread, and create a new one with your new question, to ensure maximum visibility.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi everyone!

I would like not to close this thread! I'm fighting against Crystal to process with parameters! I've tried three diferent forms and no one works!

Here is my code that throws NullPointerException.

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%

  //Crystal Java Reporting Component (JRC) imports.

%>

<%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.*"%> 

<%@page import="com.crystaldecisions.report.web.viewer.*"%>

<% //@page import="com.crystaldecisions.reports.sdk.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.*"%>

<%@page import="com.crystaldecisions.sdk.occa.report.application.ReportClientDocument"%>

<%@page import="com.crystaldecisions.reports.reportengineinterface.*"%>

<%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>

<%

  //Java imports.

%>

<%@page import="java.io.*" %>

<%@page import = "java.util.*" %>

Apoco si

<%

  String reportName = "reporteFacturas.rpt";

  try {

  //check to see if the report source already exists

  Object reportSource = null;

  //if the report source has not been opened

  if (reportSource == null) {

  //---------- Create a ReportClientDocument -------------

  ReportClientDocument oReportClientDocument = new ReportClientDocument();

  //---------- Set the path to the location of the report soruce -------------

  //Open report.

  oReportClientDocument.open(reportName, 1);

  //session.setAttribute("oClientDoc", oReportClientDocument);

  //Get the report source

  oReportClientDocument.refreshReportDocument();

  reportSource = oReportClientDocument.getReportSource();

  //session.setAttribute("reportSource", reportSource);

  //oReportClientDocument.close();

  //Cache report source.

  //This will be used by the viewer to display the desired report.session.setAttribute("reportSource", reportSource);

  CrystalReportViewer crv = new CrystalReportViewer();

  crv.setName("Crystal_Report_Viewer");

  crv.setReportSource(reportSource);

  //crv.setParameterFields(fields);

  crv.setOwnPage(true);

  crv.setOwnForm(true);

  crv.setHasToggleGroupTreeButton(false);

  crv.setEnableParameterPrompt(true);

  crv.setHasRefreshButton(true);

  crv.setDisplayGroupTree(false);

  crv.setHasLogo(false);

  //crv.refresh();

  //Passing parameters

  Fields fields1 = new Fields();

  ParameterField param1 = new ParameterField();

  param1.setReportName("");

  param1.setName("datatype");

  

  Values vals1 = new Values();

  ParameterFieldDiscreteValue val1 = new ParameterFieldDiscreteValue();

  val1.setValue(request.getParameter("datatype"));

  vals1.add(val1);

  param1.setCurrentValues(vals1);

  fields1.add(param1);

  

  //crv.setParameterFields(fields1);

  //Passing parameters

  ParameterField field = new ParameterField();

  Values vals = new Values();

  ParameterFieldDiscreteValue value = new ParameterFieldDiscreteValue();

  field.setName( "datatype" );

  value.setValue( "XML" );

  field.setReportName( "" );

  value.setDescription( "" );

  vals.add( value );

  field.setCurrentValues( vals );

  ParameterField field2 = new ParameterField();

  Values vals2 = new Values();

  ParameterFieldDiscreteValue value2 = new ParameterFieldDiscreteValue();

  field2.setName( "timestamp" );

  value2.setValue( "22536" );

  field2.setReportName( "" );

  value2.setDescription( "" );

  vals2.add( value2 );

  field2.setCurrentValues( vals2 );

  ParameterField field3 = new ParameterField();

  Values vals3 = new Values();

  ParameterFieldDiscreteValue value3 = new ParameterFieldDiscreteValue();

  field3.setName( "userform" );

  value3.setValue( "werf" );

  field3.setReportName( "" );

  value3.setDescription( "" );

  vals3.add( value3 );

  field3.setCurrentValues( vals3 );

  Fields fields = new Fields();

  fields.add(field);

  fields.add(field2);

  fields.add(field3);

  if ( fields != null )

  {

  crv.setParameterFields( fields );

  crv.setEnableParameterPrompt( false );

  }

  

  //crv.setParameterFields(fields1);

  //crv.processHttpRequest( request, response, application, null );

  //CrystalImageCleaner.start(getServletContext(),60000,12000);

  //CrystalImageCleaner.stop(getServletContext());

  crv.processHttpRequest(request, response,

  getServletConfig().getServletContext(), null);

  crv.dispose();

  }

  } catch (ReportSDKException e) {

  out.print(e);

  }

%>

Anyone has any idea!?

Former Member
0 Kudos

And this code is using the Alphonse Kouassi approach!

..These lines of code throws the NullPOinterEception:

/* This throws the NullPointer Exception */

  parameterFieldController.setCurrentValue("", "datatype", new String ("XML"));

  parameterFieldController.setCurrentValue("", "timestamp", new String ("124352"));

  parameterFieldController.setCurrentValue("", "userform", new String ("lfoerk"));

Here is the full code:

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%

  //Crystal Java Reporting Component (JRC) imports.

%>

<%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.*"%>

<%@page import="com.crystaldecisions.report.web.viewer.*"%>

<% //@page import="com.crystaldecisions.reports.sdk.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.*"%>

<%@page import="com.crystaldecisions.sdk.occa.report.application.ReportClientDocument"%>

<%@page import="com.crystaldecisions.sdk.occa.report.application.ParameterFieldController"%>

<%@page import="com.crystaldecisions.reports.reportengineinterface.*"%>

<%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>

<%

  //Java imports.

%>

<%@page import="java.io.*" %>

<%@page import = "java.util.*" %>

Apoco si

<%

  String reportName = "reporteFacturas.rpt";

  try {

  //check to see if the report source already exists

  Object reportSource = null;

  //if the report source has not been opened

  if (reportSource == null) {

  //---------- Create a ReportClientDocument -------------

  ReportClientDocument oReportClientDocument = new ReportClientDocument();

  //---------- Set the path to the location of the report soruce -------------

  //Open report.

  oReportClientDocument.open(reportName, 1);

  ParameterFieldController parameterFieldController = oReportClientDocument.getDataDefController().getParameterFieldController();

  /* This throws the NullPointer Exception */

  parameterFieldController.setCurrentValue("", "datatype", new String ("XML"));

  parameterFieldController.setCurrentValue("", "timestamp", new String ("124352"));

  parameterFieldController.setCurrentValue("", "userform", new String ("lfoerk"));

 

 

  //session.setAttribute("oClientDoc", oReportClientDocument);

  //Get the report source

  oReportClientDocument.refreshReportDocument();

  reportSource = oReportClientDocument.getReportSource();

  //session.setAttribute("reportSource", reportSource);

  //oReportClientDocument.close();

  //Cache report source.

  //This will be used by the viewer to display the desired report.session.setAttribute("reportSource", reportSource);

  CrystalReportViewer crv = new CrystalReportViewer();

  crv.setName("Crystal_Report_Viewer");

  crv.setReportSource(reportSource);

  //crv.setParameterFields(fields);

  crv.setOwnPage(true);

  crv.setOwnForm(true);

  crv.setHasToggleGroupTreeButton(false);

  crv.setEnableParameterPrompt(true);

  crv.setHasRefreshButton(true);

  crv.setDisplayGroupTree(false);

  crv.setHasLogo(false);

  //crv.refresh();

  //crv.setParameterFields(fields1);

  //CrystalImageCleaner.start(getServletContext(),60000,12000);

  //CrystalImageCleaner.stop(getServletContext());

  crv.processHttpRequest(request, response,

  getServletConfig().getServletContext(), null);

  crv.dispose();

  }

  } catch (ReportSDKException e) {

  out.print(e);

  }

%>

Thanks for any help to use this thing!

Answers (2)

Answers (2)

ted_ueda
Employee
Employee
0 Kudos

Hello Noel,

You have a JSP passing values from one place to another, and something that shouldn't be null is null.

Sincerely,

Ted Ueda

ps - you may want to describe your issue in greater detail.

Former Member
0 Kudos

Hi,

Thanks for ur reply.

I have only one jsp page. This page calls the viewer and display the report. My report will take in parameters. After entering the values and clicking ok, it display NullPointerException. It seems that the viewer didn't get the values entered. I m using the default parameter prompt provided in the "crystalreportviewers115" folder.

Regards

ted_ueda
Employee
Employee
0 Kudos

So what line of code is throwing the NPE?

I recommend providing more and detailed info.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi,

Wat are the info u need?

I have look thru the logs. There are no error stated. The only error is the one that is showed in the internet explorer: error, java.lang.NullPointerException. That's the only line.

This is my code:


<%@page import="com.crystaldecisions.reports.sdk.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.data.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>
<%@page import="com.crystaldecisions.report.web.viewer.*" %>
<%@page import="java.util.*"%>

<html>

    <body>

<%

            ReportClientDocument reportClientDoc = new ReportClientDocument();

            String report = "KL122.rpt";

            reportClientDoc.open(report, 0);

            Object reportSource = reportClientDoc.getReportSource();

            session.setAttribute("reportSource", reportSource);

            Fields oFields = new Fields();

            Calendar calendar = Calendar.getInstance();
    		calendar.set(2008,8,28);
    		Date dateParamVal = calendar.getTime();

    		setDiscreteParameterValue(oFields, "Send Date", "", dateParamVal);

			ReportExportControl exportControl = new ReportExportControl();

			ExportOptions exportOptions = new ExportOptions();

			exportOptions.setExportFormatType(ReportExportFormat.PDF);

			exportControl.setReportSource(reportSource);

			exportControl.setExportOptions(exportOptions);

			exportControl.setExportAsAttachment(true);

			exportControl.setParameterFields(oFields);

			exportControl.processHttpRequest(request, response, getServletContext(), null);
        %>
        <%!
private void setDiscreteParameterValue(Fields oFields, String paramName, String reportName, Object value) {


    ParameterField oParameterField = new ParameterField();

    oParameterField.setReportName(reportName);

    Values oValues = new Values();
    ParameterFieldDiscreteValue oParameterFieldDiscreteValue = new ParameterFieldDiscreteValue();

    oParameterField.setName(paramName);
    oParameterFieldDiscreteValue.setValue(value);

    oValues.add(oParameterFieldDiscreteValue);

    oParameterField.setCurrentValues(oValues);

    oFields.add(oParameterField);
}
        %>
</body>

</html>

Please help. I am new to crystal report and JRC. I need to solve this urgently.

Former Member
0 Kudos

Actually i dunwan to hard code the parameter values inside the jsp page. I wan the user to enter the value before the report is generated.

Former Member
0 Kudos

Hello Noel,

java.lang.nullpointerexception indicates that crystal is not getting expected values at run time.Since value is not getting correctly passed to crystal engine or nuull value is getting passed,then you can get above exception.

Please check following things at your end :

1)Parameter type set in designer and parameter which you are passing at run time should be same.

2)If you are using JDBC/ODBC connectivity, make sure that you have set environmental entries in web.xml file.

3)Make sure that parameters that you are passing should retrive some records from the database i.e Corrosponding data should be present in database for that range

Thanks,

Chinmay