It's not a secret anymore!
The moose likes Other Open Source Projects and the fly likes Jasper report + Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper report + Servlet" Watch "Jasper report + Servlet" New topic

Jasper report + Servlet

Sanket L Shah
Ranch Hand

Joined: May 08, 2009
Posts: 49
Hi All,

I am trying to use Jasper Report in my application.

try {
JasperDesign design = JRXmlLoader.load("BasicReport.xml");
JasperReport report = new JasperCompileManager().compileReport(design);
JasperPrint print = JasperFillManager. fillReport(report, parameters, new JRBeanCollectionDataSource(myList));
} catch (JRException e)
System.out.println("\n\nException \n\n");


But when it reaches the line

JasperDesign design = JRXmlLoader.load("BasicReport.xml");

it gives the exception.(Eventhough I have added the correct jar files ).. like

java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.mortbay.jetty.servlet.Holder.newInstance(
at org.mortbay.jetty.servlet.ServletHolder.getServlet(
at org.mortbay.jetty.servlet.ServletHolder.handle(
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(
at org.mortbay.jetty.servlet.ServletHandler.handle(
at org.mortbay.jetty.servlet.SessionHandler.handle(
at org.mortbay.jetty.handler.ContextHandler.handle(
at org.mortbay.jetty.webapp.WebAppContext.handle(
at org.mortbay.jetty.handler.HandlerWrapper.handle(
at org.mortbay.jetty.handler.HandlerWrapper.handle(
at org.mortbay.jetty.Server.handle(
at org.mortbay.jetty.HttpConnection.handleRequest(
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(
at org.mortbay.jetty.HttpParser.parseNext(
at org.mortbay.jetty.HttpParser.parseAvailable(
at org.mortbay.jetty.HttpConnection.handle(
at org.mortbay.thread.BoundedThreadPool$
Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRException
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 30 more

Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

It's not picking up those JAR files off the CLASSPATH, can you echo/print out what class path the report is using?

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
I agree. Here's the link:
subject: Jasper report + Servlet
It's not a secret anymore!