以下是我的代码。我希望它将alreaady制作的jrxmlFile显示为pdf,但是我得到了一个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();
}
}
堆栈跟踪:
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)
答案 0 :(得分:0)
正如您在stacktrace中看到的那样:
[javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/joda/time/ReadablePartial]
您需要将joda-time.jar
添加到类路径中。