Jump to content
Changes to the Jaspersoft community edition download ×

NoClassDefFound error on Tomcat

2005 IR Help

Recommended Posts

By: Aaron V. Humphrey - alfvaen

NoClassDefFound error on Tomcat

2003-05-30 14:04


I whipped up a little test servlet for JasperReports, which was supposed to return a PDF file. Instead, it seems to be generating an error.


The "root cause" of the error generated is:



at dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:110)

at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:219)

at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:206)


If I look at line 110 of JRFiller.java, I see:


filler = new JRVerticalFiller(jasperReport, false);


where "filler" is declared as type JRBaseFiller.


The application is deployed in a .war file with "jasperreports.jar" from the dist folder in the "lib" subfolder. That jar file seems to contain both JRVerticalFiller and JRBaseFiller classes...so I don't know what the problem might be. The error doesn't list which class is specifically "not found", unfortunately; maybe that information is lost in the ServletException above it on the error page.


My own statement that is executing is:


jpTest = JasperFillManager.fillReport(inJasper, new HashMap(), cnTest);


So it obviously doesn't even get to the stage of exporting it to PDF.


Any help is gratefully accepted.






By: Aaron V. Humphrey - alfvaen

RE: NoClassDefFound error on Tomcat

2003-06-02 08:35

Thanks, Teodor! Tomcat was in fact running on a Linux machine. I had seen some messages about this "headless" flag but hadn't been able to determine what exactly it was for, and/or how to apply it. But putting the flag into my jboss/Tomcat run.sh file did the trick. At least, that bug is not coming up anymore, and now I can concentrate on the other problems I'm having, more likely of my own making. :-)


Maybe this "headless" thing is a good candidate for the FAQ?






By: max - maxavagliano

RE: NoClassDefFound error on Tomcat

2003-06-04 22:43

We followed this error through to the ClassLoader error which basically said Access denied because a security manager.


We are newbies and have no idea what "X-server" "Xvbf" or a "-Djava.awt.headless=true. " is?? Teodor, we are running JBoss with JDK1.3.1 - what exactly do we need to do to get rid of the ClassLoader error? - same error as in Tomcat.






By: max - maxavagliano

RE: NoClassDefFound error on Tomcat

2003-07-02 23:35

In relation to our classloader error, the issue related to the library files that jasper uses (jasperreports, iText, etc ) not being found at runtime in our Ear files library folder. We had to put the jasperreports.jar in the library folder of the JBoss install and alter the classpath of the startup script for JBoss (run.sh) to allow the classes to be found. Could be a methodology issue with JBoss? But it is working now so we are happy.





By: Teodor Danciu - teodord

RE: NoClassDefFound error on Tomcat

2003-06-01 05:13




I know the error message sound strange,

but are you running on Unix/Linux?

If yes, you need X-server installed or you need to use

Xvbf or JDK1.4 with a -Djava.awt.headless=true.


I hope this helps.







By: shunbeii - shunbeii

RE: NoClassDefFound error on Tomcat

2004-09-13 00:31

hi teodord (and everyone else),


i'm having a very similar error msg of


StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception



at dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:111)

at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:222)



the problem is that i'm not running on unix or linux. i've searched the forums and this is the only place that i can find that the situation is so identical to mine.


if i try to run ant build from dos prompt, everything works fine and i can generate the pdf files.


this is my code in jsp:



DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

// Define the connection to the database

String URL="jdbc:oracle:thin:@";

String user="user";

String pass="2004";

Connection conn = null;

conn = DriverManager.getConnection (URL, user, pass);

File reportFile = new File(application.getRealPath("WEB-INF/classes/report/Report.jasper"));


JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());


JasperPrint p = JasperFillManager.fillReport(jasperReport,null,conn);






all that i want to do is to be able to run the filling from a jsp page, and then have a created pdf file according to the userid.





By: Michael Bauer - mbabauer

RE: NoClassDefFound error on Tomcat

2004-09-14 09:02

"Headless" is a term used to describe ANY server that doesn't have a GUI monitor, like many *nix machines that have only a terminal. The monitor is cosidered the head, ie not having one is called "headless".


The fix teodor suggested is available in JDK 1.4.x. Basically, Sun realized people were using the classes in the AWT to build and manipulate images and write them out as files. What the Djava.awt.headless flag does is instructs the JVM to ignore any exceptions thrown that have to do with not having a GUI when initializing the GraphicsContext. The JVM will throw a HeadlessException, however, if some request comes to display something to the screen (HeadlessException is new to JDK 1.4.x).


In the case of JasperReports, the report filler/compiler apparently uses the AWT Image classes to build the images in the report. As soon as a request for the image comes, the GraphicsContext object is created, and the exception you saw is thrown.


The other problem you may run into that I saw running JasperReports as an engine in JBoss is that the classpath isn't always what you think it might be. JBoss tends to create its own classpath for each of the servers (its actually Tomcat that holds the classpath in its ServerContext). When I ran the engine as a JSP/STRUTS/J2EE app, I found that the JRCompiler failed to compile the classes because the JasperReport classes were not in the known classpath. the fix was simple...JasperReports first tries to create the required objects, and if that fails, it then looks at a system property:


This system property can thus be set to your Tomcat classpath using the following lines:

String classpath = (String)session.getServletContext().getAttribute("org.apache.catalina.jsp_classpath");


In the example lines, session is the Servlet session (I believe the class is HttpServeltSession or something like that...its passed in to the servelt methods).


In my case, since I was using STRUTS, this code goes in my ActionClass methods that use JasperReports, but for servlets of JSPs, it would go in their respected methods. You may also set this when the servlet/jsp loads, but I haven't tried it.


I hope this explains everything well enough....good luck.

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