2011-08-09 1 views
0

私はJSFを使用してアプリケーションを開発しています。このアプリケーションはjasperReportを使用してレポートを生成し、アプリケーションはうまく動作し、レポート(pdf形式)私は、私は、アプリケーションを再実行する必要があり、それは動作しませんでした私のアプリケーションを引き続き使用しようとし、ユーザーにレポートを表示し、するjasperReportを使用してレポートを表示した後のGlassfishのシャットダウン

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(); 
     } 

私はこの問題を解決するために何をすべき?

シモンズ:私はstackflowで同じ問題が、ありません解決策を発見した(私はレポートを表示することが些細なので、私はJasperViewer.viewReport(jasperPrint)を削除したくない)

Jasper Report Generates a PDF and then Glassfish crashes/shutsdown

答えて

0

私は

JasperViewer.viewReport()、すなわち機械runni上(ローカルレポートを表示するレポートを表示することが些細だので、私はJasperViewer.viewReport(jasperPrint)を削除する必要はありませんGlassfish)を使用しているため、リモートユーザにとっては役に立たない。 PDFファイルをディスクからユーザに送信して、PDFファイルをダウンロードして開くことができます。

また、JasperReportsのJSF統合についてはhttp://jasperreportjsf.sourceforge.net/web/index.htmlをご覧ください。

0

JasperViewer.viewReport(jasperPrint); 

ラインが問題を引き起こしている場合は、のtry-catch-のThrowableでそれを取り巻く試みることができる:

try { 
    JasperViewer.viewReport(jasperPrint); 
} catch (Throwable t) { 
    t.printStackTrace(); 
} 

ここで重要なのはそのトップ、ThrowableをキャッチされますError/Exceptionのクラスであるため、のすべてをにキャッチします。特に、それはチェックされていないエラーをキャッチします - 私はあなたがそれらの1つに遭遇している可能性があると考えています。

ただし、そのメソッド内のコードがSystem.exit()を呼び出す場合は、this nice workaroundを使用できます。

関連する問題