Jump to content
Changes to the Jaspersoft community edition download ×

java.lang.NoClassDefFoundError: net/sf/jasperrepor


JasperNewBee

Recommended Posts

Hi,

 

I am trying to generate PDF reports using the Jasper Reports on the weblogic server through Eclipse.

I'm using Struts 1_0. And I have

jasperreports-1.3.1.jar, itext-1.4.8.jar and the required commons jar files too.

 

I'm getting exception when I run as a webapplication on the Weblogic Server [java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException].

 

But it works when I run it as process and even it works when I have just regular core java classes to generate PDF through main.

 

Can you please help me why this doesn't work when I run it on the Weblogic Server even after having the required jar files on the class path.

 

logs:

<Jun 15, 2007 12:00:33 PM EDT> <Error> <HTTP> <BEA-101046> <[servletContext(id=21807947,name=testingJasperReports,context-path=/testingJasperReports)] action: Dispatch[/reports] to method generateReports returned an exception

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)

at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)

at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)

at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)

at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)

at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)

at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)

at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

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

at com.testingJasperReports.SummaryReportModel.createReport(SummaryReportModel.java:77)

at com.testingJasperReports.actions.ReportGeneratorAction.generateReports(ReportGeneratorAction.java:98)

... 22 more

>

Link to comment
Share on other sites

  • 1 month later...
  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

The question in both of your cases is, in which classpath did you put the jasperreports-*.jar?

 

WebLogic is J2EE Server, so .jar(s) need to be

- put into the .ear, and

- either put into a <module> tag of the application.xml, or

- explicitly referenced by the META-INF/MANIFEST.MF Class-Path: attribute of the using ejb jar

Alternatively, there might be a server lib where it can be put ... I only use JBoss myself.

 

With applets, I'm not sure, but very probably you didn't configure it right ...

 

Hope this helps,

Sebastian

Link to comment
Share on other sites

I'm, admittedly, a total newB to jasperreports; so please forgive me.

 

 

Foreword:

By classpath I mean I changed the windows environment variable (for all users) called "CLASSPATH" to include the appropriate contents.

 

Setup (works):

I downloaded jasperreports and added the .jar files in 'dist' (jasperreports-1.3.4.jar) to the classpath, as well as some jars I needed in the 'lib' folder. I was able to use iReports just fine and created my jasper file.

 

Problem:

I compiled some java code which I'm running as an applet (maybe I should be doing this another way?) from my J2EE server. When I run the applet I get the error message that you see pasted below my code.

 

 

 

JAVA CODE:

Code:
import java.util.HashMap;

import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;

public class FirstReportFill
{
public static void main(String[] args)
{
try
{
System.out.println("Filling report..."«»);
JasperFillManager.fillReportToFile("./FirstReport.jasper",
new HashMap(), new JREmptyDataSource());
System.out.println("Done!"«»);
}
catch (JRException e)
{
e.printStackTrace();
}
}
}

 

HTML PAGE:

Code:
[code]
<html>
<head>
<title>Web Report</title>
</head>
<body>
file:///C:/Sun/SDK/docs/about.html<br>
http://localhost:8080/Test1/<br>
<APPLET CODE="FirstReportFill.class" WIDTH=100 HEIGHT=100>
</body>
</html>

 

ERROR MESSAGE:

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 sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

 

 

Feel free to make fun of me, once you figure out how ridiculously simply my problem probably is.

Link to comment
Share on other sites

CLASSPATH environment variable does not help you with an applet, as the applet is running inside the browser in a highly restricted security context.

 

But there is no reason to use an applet here ...

 

If you are using a J2EE server, why not use JasperServer?

Install JasperServer, read the guides, log in, and add the report you generated to the server, together with the required datasources. Then, you can run the report directly from the jasperserver.

 

If you get this working, you can think about putting the reporting stuff into a server application of your own ...

 

In any case, using an applet (which is executed on the clients and thus has neither access to the server-based report files, nor the server-based sql data) is not a good idea, unless you really know what you are doing, and need it.

Usually, you want to generate the report on the server and send html code with nice input controls, forward/backward buttons, page numbering and pdf/excel export to the client's browser ... and this is exactly what JasperServer does (among many other things).

 

Also, an applet does not use a main() function ...

 

Hope this helps,

Sebastian

Link to comment
Share on other sites

Äh ... where do you see the difference between Tomcat and "JasperServer on Tomcat"?

 

JS is not a standalone server, it is a web application that can be deployed on any servlet- or J2EE server, including tomcat.

 

Sebastian

Link to comment
Share on other sites

  • 1 year later...

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