2010-05-07 31 views
3

我已在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); 

這東西可以完美運行。

但我不是試圖整合JasperReportsGWT。我的服務器爲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調用,以便在單擊按鈕時使此方法起作用。

你能幫我解決這個問題嗎? (即將JasperReportsGWT合併)。

我非常感謝任何與一些代碼的解釋,因爲我只是一個初學者。

感謝

+0

你有什麼錯誤? – 2010-05-07 18:32:11

+0

是的,更好的錯誤分類肯定會有所幫助。 – markovuksanovic 2010-05-07 18:39:46

+0

我得到的錯誤是 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

回答

-1

沒有錯誤消息的幫助下,我要說的是,你有你的Eclipse項目的喜好啓用谷歌應用程序引擎。 GAE 不允許允許您寫入文件系統或調用數據庫。

嘗試禁用GAE,事情應該正常工作。

+0

他不使用GAE! – Maksim 2010-05-08 16:28:11

+0

@Maksim - 他不*故意*使用GAE。 GWT eclipse插件默認*啓用GAE。很多人默認啓用它,只有當他們遇到與上面粘貼的異常不太相同的異常時纔會實現它。 – 2010-05-08 20:23:14

+0

我們如何禁用Netbeans中的GAE? – Barry 2010-05-10 22:51:49

相關問題