Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jasper in a WebApp

 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I generated a jrxml file and a jasper file with iReport.
I made a simple swing application to generate a pdf file from those files. It worked perfectly.

Now, i tryed to integrate it into my web application.
I use the same way to generate it :


This is the content of my Servlet page. It imports the jasper classes and there isn't any compilation error.

Now, when i run it, i have some runtimes errors..



I know there is already a thread about it in this forum but it looks like he simply forgots to add jars into the classpath..
Since my servlet doesn't have any compilation errors, i guess my classpath is correct.
Here is a part of it :


I hope you can tell me what's wrong with that
Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For whatever reason, you're missing a/some required library in the deployment. Showing Ant (I assume?) stuff doesn't really tell us what's being deployed. I would have said that JR had several more dependencies than you show here, too, like iText, at the very least.
 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using WSAD.
Well, it looks like the missing classes are the ones include in jaspere2.0.2.jar .
That's why i'm so confused :s
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are they being deployed? Have you added the rest of its dependencies? I don't recall having to do anything other than deploy everything, and that was also using WSAD.
 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a good question for you >_<

How do i check it ?
 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, you were right.
It's a missing jar ! ( jdt-compiler.jar .. maybe it'll help someone else in the future ).

Still, i can't understand why i had no compilation error and why this errors happen only at runtime .. (with no details.. )
Can you explain me how to make sure we added all dependencies, how do i check what's exactly being deployed ?

Thanks a lot.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because reports in XML form are compiled at runtime if you don't pre-compile them.

Transitive dependency management is why things like Maven and Ivy were invented. You can always check the JR dependency list on their site.
 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes but the import clause from the XML file was exactly the same as the Servlet ones.

Interesting, i think i'll give it a try and use Maven or Ivy then

Thanks a lot for your help and your time.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You asked why it happened at runtime--because jrxml files are compiled at runtime.
 
Zoran Djuric
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is missing:

String h = Constants.APPLICATION_WEB_INF_PATH;
System.setProperty("jasper.reports.compile.class.path", h + "lib/jasperreports-0.6.1-processing.jar;" + h + "lib/commons-digester.jar;" + h + "classes;" + h + "lib/reports-web-src-0.1.8.jar;" + h + "lib/reports-common-src-0.1.8.jar;" + h + "lib/struts.jar;"+h+"lib/commons-lang-2.1.jar;");


If you read:
System.getProperty("jasper.reports.compile.class.path");
you will get only jasper jar file, but if inside .jrxml you use other libraries, and you want to make compile on runtime (as me on websphere), you need to add all required libraries on above system property
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic