我成功设置了 BIRT Viewer 和 PHP/Java Bridge,我可以像这样查看/打开从这个示例包中获得的“testWebReport.rptdesign”报告:
BIRT 查看器:
http://192.168.0.90:8080/birt/run?__report=report/testWebReport.rptdesign
PHP/Java 桥: 源代码/教程
<?php
define ("JAVA_HOSTS", "192.168.0.90:8080");
define ("JAVA_SERVLET", "/JavaBridge/JavaBridge.phpjavabridge");
$pth = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$path_parts = pathinfo($pth);
$imageURLPrefix = $path_parts['dirname'] ."/sessionChartImages/";
require_once("java/Java.inc");
session_start();
$here = getcwd();
$ctx = java_context()->getServletContext();
$birtReportEngine = java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx);
java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook());
try{
$report = $birtReportEngine->openReportDesign("${here}/payment.rptdesign");
$task = $birtReportEngine->createRunAndRenderTask($report);
$taskOptions = new java("org.eclipse.birt.report.engine.api.HTMLRenderOption");
$outputStream = new java("java.io.ByteArrayOutputStream");
$taskOptions->setOutputStream($outputStream);
$taskOptions->setOutputFormat("html");
$ih = new java( "org.eclipse.birt.report.engine.api.HTMLServerImageHandler");
$taskOptions->setImageHandler($ih);
$taskOptions->setBaseImageURL($imageURLPrefix . session_id());
$taskOptions->setImageDirectory($here . "/sessionChartImages/" . session_id());
$task->setRenderOption( $taskOptions );
$task->run();
$task->close();
} catch (JavaException $e) {
echo $e; //"Error Calling BIRT";
}
echo $outputStream;
?>
现在我在 BIRT for Eclipse 中创建了一个新报告,然后我尝试通过这两种方法运行它,但只有第一种方法有效。对于第二个,我收到了这条消息:
[[o:Exception]:"java.lang.Exception: Invoke failed: [[o:ReportEngine]]->openReportDesign((o:String)[o:String])。原因:org.eclipse.birt.report。 engine.api.EngineException:设计文件 file:/C:/Program%20Files%20(x86)/EasyPHP-5.3.9/www/BirtBridgeTest/payment.rptdesign 有错误,无法运行。虚拟机:1.7.0_04@http://java.oracle.com/”在:#-14 org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.getReportDesignHandle(ReportEngineHelper.java:260)#-13 org .eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:274) #-12 org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:196) #-11 org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:130) #-10 org.eclipse.birt.report.engine.api.impl.ReportEngine.openReportDesign(ReportEngine. java:304) #-9 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) #-8 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) #-7 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43) #-6 java.lang.reflect.Method.invoke(Method.java:601) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1044) #-4 php.java.bridge.Request.handleRequest(Request.java:417) #-3 php.java.bridge.Request.handleRequests(Request.java:500) #-2 php.java.bridge.http.ContextRunner.run(ContextRunner.java:145) #-1 php.java.bridge.ThreadPool $Delegate.run(ThreadPool.java:60) #0 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\java\Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(6, '@ V', 'T', true) #1 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\java\Java.inc(360): java_Arg->getResult(true) #2 C: \Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\java\Java.inc(366): java_Client->getWrappedResult(true) #3 C:\Program Files (x86)\EasyPHP-5.3.9\ www\BirtBridgeTest\java\Java.inc(560): java_Client->getResult() #4 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\java\Java.inc(1752): java_Client->invokeMethod(4, 'openReportDesig...', Array) # 5 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\java\Java.inc(1851): java_JavaProxy->__call('openReportDesig...', Array) #6 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\java\Java.inc(1999): java_AbstractJava->_call('openReportDesig...', Array) #7 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\HTMLOutput.php(20): Java-> _call('openReportDesig...' , 数组) #8 C:\Program Files (x86)\EasyPHP-5.3.9\www\BirtBridgeTest\HTMLOutput.php(20): java_InternalJava->openReportDesign('C:\Program File...') #9 {主要的}]
我已经发现导致问题的不是报告的内容,因为我创建一个与数据库连接并显示一些图表的报告或者我只是创建一个空白的报告都没有关系 - 结果是相同。
有人对此有解决方案吗?这几天真的阻碍了我的工作取得任何进展。