Jump to content
Changes to the Jaspersoft community edition download ×

Jasper/tomcat error


cdlaforc

Recommended Posts

Hello,

I'm trying to setup my first jasper report in tomcat and receiving and error. Tomcat can run the example programs that are bundled with it so I know it's working. Here is the error I receive when trying to run a static report.

 

Code:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2264)
java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2277)
java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2748)
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:191)
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:580)
net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:368)
FirstReport.doGet(FirstReport.java:27)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
filters.ExampleFilter.doFilter(ExampleFilter.java:102)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.

 

Here is the code for my java page:

Code:
[code]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperRunManager;

public class FirstReport extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletOutputStream servletOutputStream = response.getOutputStream();
InputStream reportStream = getServletConfig().getServletContext().getResourceAsStream("../reports/FirstReport.jasper"«»);

try
{
JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream,
new HashMap(), new JREmptyDataSource());

response.setContentType("application/pdf"«»);
servletOutputStream.flush();
servletOutputStream.close();
}
catch (JRException e)
{
//display stack trace in the browser
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain"«»);
response.getOutputStream().print(stringWriter.toString());
}
}

 

Please let me know if you can offer any help.

Thanks,

 

Chris.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...