-3

The following is my code. i want it to display the alreaady made jrxmlFile as a pdf, however i get an execption

Connection con = null;

try {
    Class.forName("org.apache.derby.jdbc.ClientDriver");

    con = DriverManager.getConnection("jdbc:derby://localhost:1527/WPSJSP", "athif", "athif");//dbpassword

    String jrxmlFile = "E:/web/BirthdayPie.jrxml";
    InputStream input = new FileInputStream(new File(jrxmlFile));

    JasperReport jasperReport = JasperCompileManager.compileReport(jrxmlFile);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, con);

    OutputStream outStream = response.getOutputStream();
    JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);

    response.getOutputStream().flush();
    response.getOutputStream().close();
} catch (Exception e) {
    e.printStackTrace();
} finally {
    if (con != null) {
        con.close();
    }
}

Stacktrace:

SEVERE: Servlet.service() for servlet [jsp] in context with path [/WPSJSP-CB006104] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/joda/time/ReadablePartial] with root cause
java.lang.ClassNotFoundException: org.joda.time.ReadablePartial
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1858)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:157)
    at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:115)
    at net.sf.jasperreports.functions.FunctionsBundle.addFunctionClass(FunctionsBundle.java:83)
    at net.sf.jasperreports.functions.FunctionsBundle.<init>(FunctionsBundle.java:53)
    at net.sf.jasperreports.functions.FunctionsRegistryFactory.createRegistry(FunctionsRegistryFactory.java:73)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java:239)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:214)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:162)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:133)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:105)
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:247)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.findBundles(ComponentsEnvironment.java:124)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.getCachedBundles(ComponentsEnvironment.java:114)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.getBundles(ComponentsEnvironment.java:102)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.getComponentBundles(ComponentsEnvironment.java:184)
    at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:84)

I did research a lot, including this,this and this among others. Please help.

Community
  • 1
  • 1

1 Answers1

0

As you can see in the stacktrace:

[javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/joda/time/ReadablePartial]

you need to add the joda-time.jar to your classpath.

Jens
  • 67,715
  • 15
  • 98
  • 113
  • after i added joda-time.jar i get this exception but i have added this groovy-all-2.1.2-sources jar -javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException –  May 21 '16 at 19:13
  • The you miss also some other 3rd-Party jars. In this case the groovy-all.jar – Jens May 21 '16 at 19:14
  • i did add that jar too(groovy-all-2.1.2-sources ) but still error. –  May 21 '16 at 19:16
  • You have to add the are without suffix `sources`. Do you know what sources are? – Jens May 21 '16 at 19:17
  • I am afraid i do not know what `sources ` are –  May 21 '16 at 19:19
  • 1
    sources is the java code. you need the classes (the compiled sources) which are bundlied in the groovy-all-2.1.2.jar – Jens May 21 '16 at 19:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/112586/discussion-between-alphaprogrammer-and-jens). –  May 21 '16 at 19:24