aspose file tools*
The moose likes Beginning Java and the fly likes Help with Reporting on the Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with Reporting on the Client" Watch "Help with Reporting on the Client" New topic
Author

Help with Reporting on the Client

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
I am using Websphere Development to build my web app. They have a forum but response to post is either super slow or not at all. You may have 50 or 60 views but no suggestions offering help(not always). I don't know if anyone is familiar with WSD but maybe my request is web generic anyway. My app deals with Engineering Drawing maintance. The drawings can be checked out for revisions. The revision info is stored in as400 files. The app has a user interface where they can fill out a form for the revision data. I need a way for the users to print out the revision sheet in a formated report. This formated report will also need to be generated as a pdf file at the end of an approval cycle so it can be inserted into the pdf file of the drawing. Can someone help?

I have tried to use the reportwriter included in the ibm tool kit but i get an error:

[6/22/07 13:05:06:146 CDT] 0000002d SystemOut O Ready to parse XSL document
[6/22/07 13:05:06:162 CDT] 0000002d ServletWrappe E SRVE0068E: Could not invoke the service() method on servlet ReportProcesserServlet. Exception thrown : java.lang.NoClassDefFoundError: org/apache/xerces/framework/XMLParser

on the following code in the class:

Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

I always recommend Jasper Reports. I'm not sure if this is what you are looking for, but it is a fairly powerful reporting engine and 100% Java. It will produce PDFs using iText.

But are you looking to change solutions, or to get the solution you already have working?


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
I am very new at Web Apps so your input is very important to me. What is involved in using the JasperReports? Is it expensive? Can I incorporate this into my existing app or is it an app all by itself?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
I am still needing help with getting my app data into a formated printable report. My last post asked questions about Jasper Reports.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
JasperReports is open source, so it is free to use. It's a Java library that you would incorporate into your web app. You can find more information at http://jasperforge.org/sf/projects/jasperreports, and an introduction is here.
[ June 25, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
So I can just download the jar file. Paste it into my project library files and I am ready to go. Or is it not that simple?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
It's absolutely that simple. Of course, you need to learn how to define a report, and then figure out how to use the JasperReports API to make your application generate that report, but the documentation has examples that show how to do that.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
Can you give me some low level, very simple instruction on how to get printing of formated reports to happen? I just thought I was doing good with my development until I ran into this.

I am using Websphere Development Studio Client for iSeries.

I have added the jasperreports-1.3.4.jar to my Java Build Path but whe I try:

JasperDesign jasperDesign = JasperManager.loadXmlDesign("BasicReport.xml");

in my servlet it says that it cannot be resovled.

My other alternative is using the reportwriter.jar that comes with Java ToolKit for iSeries but I cannot get that to work either.

I really need some basic help that I have not been able to find in all my searching the last four days. Excluding Sunday when I was in church praying for knowledge.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Where does your report definition file exist? It needs to be in the classpath as well.

In general, these are the steps that I use to generate a report:

1). Design the report. (I use iReport, downlodable from the JasperReports site. It is a visual report designer and builds the jrxml files for you -- you just design the report visually).

2). Compile the .jrxml files to a .jasper file (Basically, this is a Java class file that defines the report. But instead of being compiled from .java source code, it is compiled from the .jrxml file). Instructions for doing this are on the JasperReports site -- I typically do this as part of my build process with Maven/Ant (There is an Ant plugin for JasperReport)

3). I typically let my application create the data source. For simple reports that are straight database queries, Jasper will let you embed a SQL statement into the report, but for anything but basic reports I find it best to create a implementation of JRDataSource.

4). Load the .jasper file


5). Fill the report:


6). Do something with the JRPrint object:


There's many things to do with the JRPrint object; these are only a few (I think the PDF option is the most common).

Specific questions about JasperReports are probably best asked in our Other Open Source Projects forum.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
Where does your report definition file exist? It needs to be in the classpath as well.

By this do you mean that I need to edit my local Environment Variable classpath string? And if so what .jar files do I need for the jasperreports?

One more, does the classpath above make a difference when running on a web server?
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Typically, yes, the web server's classpath is independent of the environment-variable CLASSPATH. (Or, more specifically, a web server typcially sets up its own environment with its own CLASSPATH).

Where is the code that is handling the running of the report, on the client or on the server? You need the definition file to be accessible from somewhere in the classpath of whatever component it is that makes the call to


That is, in that example, the file "my/report/DefinitionFile.jasper" must be accessible through the classpath.

How did you modify the classpath to include the jasper reports jars? This should be done in the same fashion.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
When I try this line of code in my servlet I get the error "Unhandled exception type JRException"

JasperReport aReport = (JasperReport) JRLoader.loadObject("my/report/DefinitionFile.jasper");
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
Okay I have everything figured out except

JRPrint aPrint = JasperFillManager.fillReport(aReport, myParameters, myJRDataSource);

What if I don't have any myParameters(this is only a test)
and no myJRDatasource(thisis only a test)?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
Well I got that figured out by creating a Map and Connection object and leaving them empty. Now I get an error that my .jasper file cannot be found.

I have it located in the WebContent folder,
WebContent/WEB-INF/class folder,
WebContent/WEB-INF/lib folder,
my package folder,
my package/JavaSource folder
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

What is the exact line of code that you are using to load the .jasper file, and what is the structure of your WEB-INF folder?

I would, for now, place the .jasper file under the WEB-INF/classes folder, so if your line of code was


JasperReport aReport = (JasperReport) JRLoader.loadObject("my/report/DefinitionFile.jasper");

then I would expect to see a file

WEB-INF/classes/my/report/DefinitionFile.jasper
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
My WEB-INF structure Starts with project name:

DrawingPDMW1/WebContent/WEB-INF/Classes/JRtest1.jasper

My calling line of code:

JasperReport aReport = (JasperReport) JRLoader.loadObject("WEB-INF/classes/JRtest1.jasper");
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
One more thing. If I use this calling line of code:

JasperReport aReport = (JasperReport) JRLoader.loadObject("\\\\gvsvr03\\users\\sde\\drawingpdmw1\\webcontent\\JRtest1.jasper");

I get a different error:

[6/26/07 13:57:43:449 CDT] 0000003e SystemOut O net.sf.jasperreports.engine.JRException: Class not found when loading object from file : \\gvsvr03\users\sde\drawingpdmw1\webcontent\JRtest1.jasper
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Just try:

JasperReport aReport = (JasperReport) JRLoader.loadObject("JRtest1.jasper");


Since WEB-INF/classes should already be part of the classpath, you shouldn't need to specify it.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
I have tried this and it will not work.

This is the error I get:

[6/26/07 14:14:31:907 CDT] 0000003e SystemOut O net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: JRtest1.jasper
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
I finally got this to work after I added so more jar files:

JasperReport aReport = (JasperReport) JRLoader.loadObject("\\\\gvsvr03\\users\\sde\\drawingpdmw1\\webcontent\\JRtest1.jasper");

However, the jasper file I compiled from iReport has a title on it(just a test) but when the pdf file is generated it is blank.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Add the bolded line to the report:
<jasperReport
name="myReport"
....
whenNoDataType="AllSectionsNoDetail"

Alternatively, if you are using iReport, this is found underneath the Edit->Report Properties menu item, on the "More..." tab.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1446
    
    1
Have you given any more thought to why I can not use simple object name to access the jasper file. I am afraid I am going to have trouble if the only way it will work is a fully qualified network path.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Reporting on the Client