Jump to content
We've recently updated our Privacy Statement, available here ×

Help filling and viewing a report


2005 IR Help

Recommended Posts

By: Marc - kantspel

Help filling and viewing a report

2004-08-18 14:53

Hi guys.

I posted this question on the iReports forum, and I got a some help (thanks c-box & jubyvictor), but I was wondering if anyone else has any other ideas, because I still haven't been able to figure out the problem.

Basically what I want to do is to pass an orderID from my webpage to the report through the URL like this:

http://server/webapp/MakeReport.do?orderID=3, and then have a pdf pop up.

I designed and tested my report in iReports, and it works properly.

However, when I try and run the page, it shows up blank. If I press the refresh button, I get a java.lang.NullPointerException from Tomcat.

I also use a text logger, and this is the error I get:

[ERROR] Tue. 10:21:23.640 p.m. - From Class [reports.OrderForms], From Method [execute] - JRException: net.sf.jasperreports.engine.JRException: Class not found when loading object from file : C:Program FilesApache GroupTomcat 4.1webappsdwPlugsreportsOrderForm.jasper.

 

Here is my entire action:

package reports;

 

import java.io.IOException;

import net.sf.jasperreports.engine.JRException;

import java.util.HashMap;

import net.sf.jasperreports.view.*;

import net.sf.jasperreports.engine.util.*;

import net.sf.jasperreports.engine.*;

import javax.servlet.http.*;

import org.apache.struts.action.*;

import java.sql.*;

import utilities.*;

import beans.*;

 

public final class OrderForms extends Action

{

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response)

{

ActionForward nextPage = null;

DBConnectionManager conMan = null;

Connection dbConn = null;

int orderID = 4;

 

try

{

conMan = DBConnectionManager.getInstance();

dbConn = conMan.getConnection("dwPlugs");

dbConn.setAutoCommit(false);

 

String report = "C:\Program Files\Apache Group\Tomcat 4.1\webapps\dwPlugs\reports\OrderForm.jasper";

JasperReport myRep = JasperManager.loadReport(report);

HashMap parameters = new HashMap();

parameters.put("orderID", String.valueOf(orderID));

JasperPrint jasperPrint = JasperFillManager.fillReport(myRep, parameters, dbConn);

 

dbConn.commit();

dbConn.setAutoCommit(true);

conMan.freeConnection("dwPlugs",dbConn);

nextPage = mapping.findForward("success");

}

catch (SQLException sqle)

{

TextLogger.error("SQL Error in InventoriesActionAdd: " + sqle);

try

{

dbConn.rollback();

dbConn.setAutoCommit(true);

conMan.freeConnection("dwPlugs",dbConn);

}

catch (SQLException sqle2)

{

TextLogger.error("SQL Error in InventoriesActionAdd rollback: " + sqle2);

}

nextPage = mapping.findForward("failure");

}

catch (JRException e)

{

TextLogger.error("JRException: " + e);

}

 

return nextPage;

}

}

 

I have also tried using:

JasperReport myRep = (JasperReport) JRLoader.loadObject(fileNameOfMyReportAsJasper);

instead of:

JasperReport myRep = JasperManager.loadReport(fileNameOfMyReportAsJasper)

 

I don't know how to get rid of these errors, does anyone have any suggestions? I'm almost beginning to wonder if jasper reports is set up correctly.

 

Thanks in advance,

Marc

 

 

 

 

By: Richard Barnett - richard_barnett

RE: Help filling and viewing a report

2004-08-18 18:46

Looks like a classpath/classloader problem. Make sure your web/app server can find the the Jasper jar & its dependencies.

 

 

 

 

By: Marc - kantspel

RE: Help filling and viewing a report

2004-08-19 17:12

Hi.

 

I added the two jasperreports .jar files to my classpath, but what would dependencies entail? Perhaps those are what I'm missing.

 

Thanks

Marc

 

 

 

 

By: Richard Barnett - richard_barnett

RE: Help filling and viewing a report

2004-08-19 17:28

Jars as described in <http://jasperreports.sourceforge.net/requirements.html> (required versions will vary depending on the version of JasperReports you're using).

 

 

 

 

By: Richard Barnett - richard_barnett

RE: Help filling and viewing a report

2004-08-19 17:35

Are you sure that the JasperReports version you're using to compile the .xml to .jasper is the same as the version you're using to load the .jasper?

 

Are you sure that the .jasper file isn't 0-length or corrupted?

 

Does it work if you compile the .xml to a JasperReport instance, rather than loading the precompiled one from .jasper?

 

 

 

 

By: Marc - kantspel

RE: Help filling and viewing a report

2004-08-22 10:13

Hi there, sorry I was away for a few days.

I actually am using iReport to compile my reports.

Yup I'm pretty sure the .jasper file isn't corrupted.

How would I compile it to a JasperReport instance?

 

Thanks

Marc

 

 

 

 

By: Richard Barnett - richard_barnett

RE: Help filling and viewing a report

2004-08-19 17:39

Are the jars in your web module's manifest?

 

 

 

 

By: Marc - kantspel

RE: Help filling and viewing a report

2004-08-22 10:17

I'm not totally sure what you mean by that, I'm a bit of a newbie ;)

But if you mean the classpath, then yes, I added the two jasperreports jars.

 

 

 

 

 

By: Richard Barnett - richard_barnett

RE: Help filling and viewing a report

2004-08-22 17:39

I don't know anything about Tomcat & you don't say what version you're using. The Deployment section in http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/index.html suggests a couple of dirs where you can put library jars to make them available to the web app. I'm sure the docs for older Tomcat versions contain similar sections.

 

(Websphere, which I'm using, requires you to list them in a manifest.mf file.)

 

You'd use the JasperManager class to compile an XML design: loadXmlDesign() then compileReport() to get a JasperReport instance.

 

 

 

 

By: Marc - kantspel

RE: Help filling and viewing a report

2004-08-22 20:59

I'm using Tomcat 4.1.

Maybe I should upgrade to Tomcat 5.0, it might make things a bit easier.

 

Ok, thanks for your help! :D

 

Marc

 

 

 

 

By: Marc - kantspel

RE: Help filling and viewing a report

2004-08-23 19:58

OK I figured out something!

 

Here is what is causing the error:

 

java.lang.ClassNotFoundException: dori.jasper.engine.JasperReport

 

How do I make this class found?

I tried placing both jars in the $CATALINA_HOME/common/lib directory and restarting tomcat, and it didn't work.

 

Does anybody have any suggestions?

 

Thanks

Marc

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...