Jump to content

JBoss / JasperReports throws NoClassDefFoundError


aharshbarger

Recommended Posts

We've been using JasperReports for the last few years is contained in an EAR file that runs within the JBoss Application server. These reports are precompiled before they are packaged within the EAR/WAR file.

 

 

When we first used JasperReports , we were running JBoss 4.0.1. When we upgraded JBoss to v4.0.3, we had an issue with JasperReports throwing a java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException whenever a report was executed.

 

 

After many hours of research, I found that if the 'UseJBossWebLoader' attribute within the jboss-service.xml file of the embeded Tomcat service was modified to 'true' from it's default 'false'.....JasperReports works without any issues?? The comment for this attribute indicates that if it's false, then any war within the AppServer will be isolated from each other (i.e. their libraries). From the description, it sounds like this would be something that would be very beneficial giving the fact that we could be running multiple WARs within the same App Server. But since we were rushed, we just changed the attribute to true and forgot about it.

 

 

At the time of the JBoss 4.0.3 upgrade, we were using JasperReports 1.2.3. We are now looking at upgrading JasperReports to either the latest 1.x version or 2.0. I've tested them both with JBoss 4.0.4 and JBoss 4.2.1 and had to change that

'UseJBossWebLoader' attribute from its default value of 'false' to 'true' in order to get JasperReports to work.

 

 

 

Here is the comment that explains the UseJBossLoader attribute

 

<!-- A flag indicating if the JBoss Loader should be used. This loader

uses a unified class loader as the class loader rather than the tomcat

specific class loader.

The default is false to ensure that wars have isolated class loading

for duplicate jars and jsp files.

-->

<attribute name="UseJBossWebLoader">false</attribute>

 

 

Also, here is a more in-depth trace of the exception being thrown:

 

javax.servlet.ServletException: Servlet execution threw an exception

org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

 

 

root cause

 

java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException

 

 

 

Additional Environment info:

Machine: x86

OS: Windows XP / Server 2003

JDK: JDK 1.4.2 / 1.5.0 (Tried both)

Server: JBoss 4.0.3 / 4.0.4 / 4.2.1 (Tried all)

Comments: In addtion, we use Struts, Tiles, JSPs, Servlets

 

 

 

 

Any ideas on how we can get around with having to turn off the isolated WAR feature? Any help would be greatly appreciated.

 

 

-Aaron

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Hi!

You have an .ear that contains the .war, OK.

 

Where do you put the Jasper-jars?

Inside the WEB-INF/lib of the .war, inside the .ear, or somewhere else?

 

Where are the compiled reports? In the .war itself, or in an additional EJB .jar inside the .ear?

 

We are using JS on JBoss, but putting without putting the .war into another .ear, but we've got some experience with class-path settings in .ear/.jar ... maybe we can help there?

 

Yours,

Sebastian

Link to comment
Share on other sites

Hello,

We have an .EAR that contains the .WAR file. The jasper jars are within the WEB-INFlib. The compiled reports are within the WEB-INFclassesreports and are accessed by action classes (Struts) / servlets.

 

 

NOTE: The Manifest.MF file in both the WAR and EAR do not reference the jasper jars.

 

 

I hope this information helps. I would really like to keep the EAR/WARs J2EE standardized and isolated if possible. We currently support JBoss, but will have to support other J2EE vendors in the future.

 

 

Thanks,

-Aaron

Link to comment
Share on other sites

Hi!

I tried some stuff ... using the jasperserver.war as the .war inside the .ear, it works w/o any problems, with UseJBossWebLoader=false and =true. I can't reproduce your problem ...

 

When you deploy the .war w/o the .ear, do you get the same error, or does it work both ways with UseJBossWebLoader?

 

Maybe you can try to use JasperServer as a test setup ... configure the jasperserver.war to work with JBoss (remove log4j, add jboss-web.xml), pack it into an .ear, and try to deploy it with true/false settings ... maybe this can help finding out whether the problem is with your ear/war, or with the JBoss itself?

 

Seems I have to admit defeat ...

Sebastian

Post edited by: csbac, at: 2007/08/28 13:49

Link to comment
Share on other sites

Hi Sebastian!

The problem occurs as soon as I try to run a report. When I start the server, I don't get the error. I wasn't sure by your response as to which approach you tried.

 

 

After posting my first reponse to your questions, I started to think about my NOTE I posted. I thought I've tried putting the .jar's in the EAR instead and then reference them from within the Classpath in my WAR/META-INF/MANIFEST.MF...but I thought I would try it again. I put the JasperReport, iTest, and jxl jars in the EAR /lib/*.jar instead of within the WAR/WEB-INF/lib/*.jar folder. I then referenced the jar's from within the 'Class-path:' variable in the WAR/META-INF/MAINFEST.MF file. After making these changes, the reporting engine can now be found when running in JBoss with the 'UseJBossWebLoader' attribute set to true or false.

 

 

Are there any drawbacks that you can see with having some of these libraries at the EAR level instead of the WAR level? And then the WAR referencing them from it's 'Class-path' variable in the manifest? I'm not sure why they won't work when they are within the WAR file because they are only referenced within the WAR. The only thing I can think of is that the error seems to be coming from a servlet...and maybe that's at a higher level??

 

 

javax.servlet.ServletException: Servlet execution threw an exception

 

org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

 

 

I think the problem is resolved, but I would like to have your thoughts on the resolution that I believe has been found. I also hope this resolution would still work when running within the other J2EE vendors.

 

 

Thanks Again!

Aaron

Link to comment
Share on other sites

Hi!

Of course, I also ran reports, not just deployed ;-)

 

Referencing the .jars from the Manifest is a solution, but one that is rather for J2EE applications, or even more simple .jar starters, I'd say, than for web applications. If you just forget to name one of the jars in the Class-Path, or a version number is changed, the stuff no longer works ... or even worse, most things work, but some special cases don't ...

 

You have a web application ... so it should be possible to use the web archive way of including jars ... which is WEB-INF/lib ... and it does not work in your case. Strange, yet I remember something like this some time ago as well .. can't remember which context, though ... maybe I rememeber in a few days. For the moment, I've got no idea ...

 

Yours,

Sebastian

Link to comment
Share on other sites

Hello,

I guess I forgot to mention that I couldn't just deploy the WAR outside of the EAR beacuse I also have EJB's that is needed by the WAR in order to run the applications. The EAR serves up both web based clients as well as other clients that interface with the EJB's directly.

 

 

If you do remember any reference to someone else having the same type of problem and their solution, please let me know. For now, I'll just have to keep it the way it is. I use an ANT file to compile, package, etc my EAR file. So the referencing of the JARs is all in one place within the script. It then takes care of ensuring that they are included in the right areas when it's built.

 

 

Thanks again,

-Aaron

Link to comment
Share on other sites

Hello,

The servlets are currently the only ones that use JasperReports libraries, which is why we originally had them in the WAR only. However, there is a possibility in the future that the backend may need to use JasperReports for automatically generating and sending off reports via email, etc. At the time of starting out with JasperReports, we were just worrying about focusing on the initial need and then worry about the other possible needs when it they happen. But now that I have the JasperReports at the EAR level, there should be no problem with the EJB's using the same libraries.

 

 

-Aaron

Link to comment
Share on other sites

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