我已在NetBeans
平臺集成JasperReports
和我能夠生成使用下面的代碼報道:獲取java.lang.NoSuchMethodError例外當使用GWT + JasperReports的
Map<String, Object> params = new HashMap<String, Object>();
Connection conn = DriverManager.getConnection("databaseUrl", "userid", "password");
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn);
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
這東西可以完美運行。
但我不是試圖整合JasperReports
與GWT
。我的服務器爲GlassFish
服務器。
我使用的followind代碼獲取Connection對象:
public static Connection getConnection() {
try {
String JNDI = "JNDI name";
InitialContext initCtx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) initCtx.lookup(JNDI);
Connection conn = (Connection) ds.getConnection();
return conn;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
然後
Map<String, Object> params = new HashMap<String, Object>();
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, getConnection());
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
但我總是得到一個錯誤。這裏是一個堆棧跟蹤:
com.google.gwt.user.server.rpc.UnexpectedException:
Service method 'public abstract java.lang.Boolean com.client.service.GenerateReport()'
threw an unexpected exception: java.lang.NoSuchMethodError:
net.sf.jasperreports.engine.fonts.SimpleFontFamily.setExportFonts(Ljava/util/Map);
我正在實施此服務器上。我正在進行RPC調用,以便在單擊按鈕時使此方法起作用。
你能幫我解決這個問題嗎? (即將JasperReports
與GWT
合併)。
我非常感謝任何與一些代碼的解釋,因爲我只是一個初學者。
感謝
你有什麼錯誤? – 2010-05-07 18:32:11
是的,更好的錯誤分類肯定會有所幫助。 – markovuksanovic 2010-05-07 18:39:46
我得到的錯誤是 com.google.gwt.user.server.rpc.UnexpectedException:服務方法'公共抽象java.lang.Boolean com.client.service.GenerateReport()'拋出一個意外的異常:java。 lang.NoSuchMethodError:net.sf.jasperreports.engine.fonts.SimpleFontFamily.setExportFonts(Ljava/util/Map); – Barry 2010-05-10 21:36:01