我正在使用 Apache+PHP、Tomcat 和 JavaBridge 运行测试,以尝试加载 BIRT 并呈现文档。这是 PHP 文件:
<?php
ini_set('display_errors','On');
error_reporting(E_ALL);
require_once('http://127.0.0.1:8081/Bridge/java/Java.inc');
$here = getcwd();
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}/TopNPercent.rptdesign");
$task = $birtReportEngine->createRunAndRenderTask($report);
$taskOptions = new java("org.eclipse.birt.report.engine.api.PDFRenderOption");
$outputStream = new java("java.io.ByteArrayOutputStream");
$taskOptions->setOutputStream($outputStream);
$taskOptions->setOutputFormat("pdf");
$task->setRenderOption( $taskOptions );
$task->run();
$task->close();
} catch (JavaException $e) {
echo $e; //"Error Calling BIRT";
}
//echo $outputStream;
echo java_values($outputStream->toByteArray());
?>
一旦我通过 Apache+PHP 访问它,我就会收到以下错误:
<br />
<b>Fatal error</b>: Uncaught [[o:Exception]:"java.lang.Exception:
ReferenceClass failed: new org.eclipse.birt.php.birtengine.BirtEngine. Cause:
java.lang.ClassNotFoundException: org.eclipse.birt.php.birtengine.BirtEngine VM:
1.7.0_04@http://java.oracle.com/" at:
#-10 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438)
#-9 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
#-8 java.lang.Class.forName0(Native Method)
#-7 java.lang.Class.forName(Unknown Source)
#-6 php.java.bridge.Util.classForName(Util.java:1518)
#-5 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445)
#-4 php.java.bridge.Request.handleRequest(Request.java:444)
#-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 http://127.0.0.1:8081/Bridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(3, 'org.apache.cata...', 'T', false)
#1 http://127. in <b>http://127.0.0.1:8081/Bridge/java/Java.inc</b> on line <b>195</b><br />
127.0.0.1:8081 是 Tomcat 服务器。似乎无法找到“org.eclipse.birt.php.birtengine.BirtEngine”类。我将 birt-runtime-3_7_2/lib 文件夹的内容复制到 JavaBridge 的 WEB-INF/lib 中,但没有帮助。我已经尝试在各个站点上搜索答案,但唯一一个,我认为实际上没有答案的相同问题在这里:LINK。有谁知道这个问题的解决方案或如何让 JavaBridge 看到那个类?