Hi,
I'm developing an applet that displays a table from a HSQLDB database and I would like to integrate a report printing feature.
I integrated in the start method of the applet the following code:
.........
String birthome = System.getProperty("user.dir")+System.getProperty("file.separator")+"birt-runtime-2_3_2/ReportEngine/";
config = new EngineConfig( );
// config.setProperty("BIRT_HOME", home+"birt-runtime-2_3_2/ReportEngine/");
config.setProperty("BIRT_HOME", birthome);
config.setLogConfig(home, Level.SEVERE);
config.setLogFile("errori.txt");
PlatformConfig pc = new PlatformConfig();
pc.setBIRTHome(birthome);
PlatformFileContext context = new PlatformFileContext(pc);
config.setPlatformContext(context);
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
.....
with the exception catching. Then I added a method to print the report with the data obtained by a query on my database:
public void Stampa() throws BirtException, IOException, SQLException {
// String filereport = "/home/sviluppo/albo.rptdesign";
String filereport = System.getProperty("user.home");
filereport += System.getProperty("file.separator");
filereport += "albo.rptdesign";
IReportRunnable runnable = null;
try {
String output = filereport.replaceFirst(".rptdesign", ".pdf");
// String output = home+"albo.pdf";
runnable = engine.openReportDesign(filereport);
/* Oggetti ReportDesignHandle e OdaDataSetHandle per passare al data set la query aggiornata
* C. Carlucci 05/06/2009
*/
ReportDesignHandle handle = (ReportDesignHandle) runnable.getDesignHandle();
OdaDataSetHandle ds = (OdaDataSetHandle) handle.findDataSet("Data Set");
// String queryrs = "SELECT * FROM TABISCRITTI WHERE LOCNASCITA = 'BARI'";
if (! query.isEmpty()) {
ds.setQueryText("SELECT * FROM TABISCRITTI WHERE "+query);
} else {
ds.setQueryText("SELECT * FROM TABISCRITTI");
}
IRunAndRenderTask task = engine.createRunAndRenderTask(runnable);
/*
HTMLRenderOption option = new HTMLRenderOption( );
option.setOutputFileName(output);
option.setOutputFormat("html");
*/
PDFRenderOption option = new PDFRenderOption();
option.setOutputFileName(output);
option.setOutputFormat("pdf");
task.setRenderOption(option);
task.run();
task.close();
} catch (EngineException e) {
System.out.println("Errore di engine!");
}/* finally {
engine.destroy();
Platform.shutdown();
}*/
}
My problem is that the report generation operates well from the applet viewer in Eclipse environment, but when I try to call the applet from an html file, the applet displays well, but the report engine doesn't operate. So I cannot generate my report. In the java console of the browser (Firefox) I get the following error:
org.eclipse.birt.core.exception.BirtException: Cant startup the OSGI framework
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:91)
at albo.start(albo.java:398)
at sun.applet.AppletPanel.run(AppletPanel.java:465)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.eclipse.birt.core.exception.CoreException
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:90)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:79)
... 3 more
Why the platform startup fail? It depends on the signing of the various jar of my applications? Here's the code of the index.html that calls my applet:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Albo Ingegneri Provincia di Bari</title>
<meta name="author" content="sviluppo">
<meta name="generator" content="Bluefish 1.0.7">
<meta name="description" content="" >
<meta name="keywords" content="" >
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" >
<meta http-equiv="Content-Script-Type" content="text/javascript" >
<meta http-equiv="Content-Style-Type" content="text/css" >
</head>
<body>
<CENTER><H1>Ordine degli Ingegneri della Provincia di Bari</H1></CENTER>
<CENTER><H3>Albo Elettronico 2009</H3></CENTER>
<CENTER>
<APPLET code="albo.class" archive="signedalbo.jar, lib/signedcommons-cli-1.0.jar, lib/signedhsqldb.jar, lib/signedcom.ibm.icu_3.8.1.v20080530.jar, lib/signedcoreapi.jar, lib/signeddataadapterapi.jar, lib/signeddteapi.jar, lib/signedengineapi.jar, lib/signedjs.jar, lib/signedmodelapi.jar, lib/signedodadesignapi.jar, lib/signedscritpapi.jar" width="1024" height="768" align="center"></APPLET>
</center>
</body>
</html>
The applet read my signedalbo.jar and make the database jdbc connection reading the lib/signedhsqldb.jar file. But can't start the OSGI. I missed something? Please help me! Thank you!