views:

308

answers:

1
+1  Q: 

Java and Jasper

Hey Guys, I have integrated Jasper Reports on my netbeans platform and i am able to generate reports using the following code.

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

This stuff works perfect.

But not i am trying to integrate Jasper with GWT.I have my server as glass fish server.

I am getting the Connection object using the followind code.

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

and then

Map params = new HashMap(); JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, getConnection()); JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest); JasperViewer.viewReport(jasperPrint);

but i always get Error.I am implementing this on Server.I am having RPC calls to get this method to work when a button is clicked.

Can you please help me how to work on this.(That is to integrate Jasper reports with GWT).

I would highly appreciate any explanation with some code as i am just a beginner.

Thanks

A: 

Without the aid of error messages, I would say that you have Google App Engine enabled in your eclipse project preferences. GAE does NOT allow you to write to the file system, or make calls to a database.

Try disabling GAE, and things should work fine.

sri
He does not use GAE!
Maksim
@Maksim - He does not *intentionally* use GAE. The GWT eclipse plugin *by default* has GAE enabled. Many, many people have it enabled by default, and realize it only when they encounter an exception not too different from the one pasted above.
sri
@sri :How do we disable GAE in Netbeans?
bhargava
Netbeans doesn't have a GWT plugin, so unless you have downloaded GAE and have included the jars, I don't think GAE is the problem. Since you are getting NoSuchMethodError, its possible you have conflicting jars in your classpath. I am guessing two jars have different versions of `net.sf.jasperreports.engine.fonts.SimpleFontFamily`.
sri
I cleaned up my library and made sure that i have only one copy of jar files in my library.But still i get the same error which i copy pasted before.Is there some thing which i am missing still?
bhargava