【发布时间】:2011-10-23 04:51:32
【问题描述】:
我正在使用 JSF 开发一个应用程序,我正在使用 Glassfish 服务器,该应用程序使用 jasperReport 生成报告,该应用程序工作正常并生成报告(pdf 格式),这些报告存储在我的磁盘上,问题是当我使用
JasperViewer.viewReport(jasperPrint);
要向用户显示报告,然后尝试继续使用我的应用程序它不起作用,我应该重新运行应用程序!
在控制台上的错误是:
Completed shutdown of Log manager service
我的代码:
public void fillReport() throws ParseException, groovyjarjarcommonscli.ParseException {
try {
// - Connexion à la base
Driver monDriver = new com.mysql.jdbc.Driver();
DriverManager.registerDriver(monDriver);
connection = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/Mybase", "root", "root");
// - Chargement et compilation du rapport
JasperDesign jasperDesign = JRXmlLoader.load("C:/Documents and Settings/report2.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
Map parameterMap = new HashMap();
parameterMap.put("DateFrom", formatingDateTime(date1));
parameterMap.put("DateTo", formatingDateTime(date2));
parameterMap.put("SQL", Createquery());
// // - Execution du rapport
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap, connection);
JasperViewer.viewReport(jasperPrint);
JasperExportManager.exportReportToPdfFile(jasperPrint,"C:/Documents and Settings/report2.pdf");
} catch (JRException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
connection.close();
}
我应该怎么做才能解决这个问题?
Ps:我在 stackflow 上发现了同样的问题,但没有解决方案(我不想删除 JasperViewer.viewReport(jasperPrint),因为显示报告对我来说很简单)
Jasper Report Generates a PDF and then Glassfish crashes/shutsdown
【问题讨论】:
标签: java jasper-reports glassfish