これが私のGeneratePdf.javaインポートです...
public class GeneratePdf {
public static void main(String[] args) {
try {
JRDataSource ds = getDatasource();
// - Chargement et compilation du rapport
line32 JasperDesign jasperDesign = JRXmlLoader.load("/home/gocoffee.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
// - Paramètres à envoyer au rapport
Map parameters = new HashMap();
parameters.put("Titre", "Titre");
// - Execution du rapport
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
parameters, ds);
// - Création du rapport au format PDF
JasperExportManager.exportReportToPdfFile(jasperPrint, "home/test2.pdf");
} catch (JRException e) {
}
}
Mongo接続とデータの取得():
private static JRDataSource getDatasource() {
// Retrieve session
try{
Mongo m = new Mongo("localhost", 27017);
DB db = m.getDB("test");
DBCollection t = db.getCollection("test");
List<DBObject> list = t.getIndexInfo();
JRDataSource ds = new JRBeanCollectionDataSource(list);
return ds;
} catch (UnknownHostException e) {
System.out.println("Error mongo connection");
} catch (Exception e) {
System.out.println("Other Exception");
}
return null;
}
}
このエラーが発生しましたが、理解できません。
run:
17-Feb-2012 17:07:26 org.apache.commons.digester.Digester endElement
SEVERE: End event threw exception
java.lang.reflect.InvocationTargetException
....
....
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
at GeneratePdf.main(GeneratePdf.java:32)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'MongoDbQuery' language.
at net.sf.jasperreports.engine.util.JRQueryExecuterUtils.getQueryExecuterFactory(JRQueryExecuterUtils.java:64)
at net.sf.jasperreports.engine.design.JRDesignDataset.queryLanguageChanged(JRDesignDataset.java:1122)
at net.sf.jasperreports.engine.design.JRDesignDataset.setQuery(JRDesignDataset.java:600)
at net.sf.jasperreports.engine.design.JasperDesign.setQuery(JasperDesign.java:789)
... 28 more