Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JasperReport Fehler /PHP Java Bridge

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich versuche die Funktionalität von Java-Bibliothek JasperReport in PHP-Umgebung mit PHP Java Bridge zu testen. Allein mit Java habe ich den gleichen Script schon getestet und es funktioniert einwandfrei.

Wenn ich aber meinen PHP-Script aufrufe, bekomme ich foldenden Java-Fehler:

--------------------------------------------------------------------------

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:JasperCompileManager]]->compileReport((o:String)[o:String]). Cause: net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException: Premature end of file. Responsible VM: 1.6.0_13@http://java.sun.com/" at: #-15 net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243) #-14 net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226) #-13 net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214) #0 http://localhost:8080/JavaBridge/java/Java.inc(255): java_ThrowExceptionProxyFactory->getProxy(3, 'net.sf.jasperre...', true) #1 http://localhost:8080/JavaBridge/java/Java.inc(471): java_Arg->getResult(true) #2 http://localhost:8080/JavaBridge/java/Java.inc(477): java_Client->getWrappedResult(true) #3 http://localhost:8080/JavaBridge/java/Java.inc(672): java_Client->getResult() #4 http://localhost:8080/JavaBridge/java/Java.inc(1783): java_Client->invokeMethod(2, 'compileReport', Array) #5 http://localho in http://localhost:8080/JavaBridge/java/Java.inc on line 218

--------------------------------------------------------------------------

Und das ist der Quellcode:

<?php

// PDF-Erzeugung

$settingsPath = "includes/settings/";

$JavaBridge = file_get_contents($settingsPath . 'javaBridgePath.inc');

$jasperReportsLib = file_get_contents($settingsPath . 'jasperReportsLibPath.inc');

require_once($JavaBridge);

$xml_datei = "personen_db.xml";

$xpath = "/personen/person";

$jrxml_datei = "personen_db.jrxml";

$pdf_datei = "personen_db.pdf";

$handle = @opendir($jasperReportsLib);

while(($new_item = readdir($handle)) !== false)

{

$java_library_path .= 'file:'.$jasperReportsLib.'/'.$new_item .';';

}

java_require($java_library_path);

// einlesen des XML-Files, erzeugt JR-Datenquelle:

$ds = new Java("net.sf.jasperreports.engine.data.JRXmlDataSource",$xml_datei,$xpath); //Bis dahin komme ich durch!

// einen zunächst leeren Report aus dem XML erzeugen:

$sJcm = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); //Bis dahin komme ich durch!

$report = $sJcm->compileReport($jrxml_datei); //Hier steige ich schon aus!

// den neuen Report mit Daten füllen

$sJfm = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");

$print = $sJfm->fillReport($report, new Java("java.util.HashMap"), $ds);

// Umwandlung in PDF:

$sJem = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");

//$sJem->exportReportToPdfFile($print, $pdf_datei);

echo "PDF wurde erstellt!";

?>

Ich bin hier im Forum, weil das eigentlich ein Java-Fehler ist und mit PHP nicht zu tun hat. Kann mir jemand helfen?

Hallo!

Danke tausend mal!!! Es lag wirklich an der xml-Datei. Ich habe eine andere ausgetestet, bei der ich 100% sicher war und es hat funktioniert!!! Warum Kaum zu glauben!!! Danke sehr!!!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.