0

I'm running a test using Apache+PHP, Tomcat and JavaBridge to try to load BIRT and render a document. This is the PHP file:

<?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());
?>

Once I access it through Apache+PHP i receive the following error:

<br />
<b>Fatal error</b>:  Uncaught [[o:Exception]:&quot;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/&quot; 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-&gt;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 is Tomcat server. It seems it isn't able to find "org.eclipse.birt.php.birtengine.BirtEngine" class. I copied birt-runtime-3_7_2/lib folder's contents to JavaBridge's WEB-INF/lib but it doesn't help. I've tried searching for the answer on various sites, but the only one, I think actualy the same problem with no answer is here: LINK. Does anyone know a solution to this problem or how to make that JavaBridge would see that class?

Community
  • 1
  • 1
Copperis
  • 1
  • 1

2 Answers2

0

I'm not certain require_once takes URL as parameters. Have you tried an absolute path to the file instead? Mine looks like this: "C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/JavaBridge/java/Java.inc" and it works.

Also, you might want to look at this article which details the proper configuration steps:

http://www.birt-exchange.org/org/devshare/deploying-birt-reports/743-calling-birt-from-php/

Anyway, best of luck to you, I know I lost quite a few hair when I had to do this configuration.

Osuwariboy
  • 1,335
  • 1
  • 14
  • 29
0

You were on the right path by copying birt_runtime jars to JavaBridge/WEB-INF/lib. The missing org.eclipse.birt.php.birtengine.BirtEngine is inside birtEngine.jar file. Look for it on the web, it only has that single missing class.

Striker
  • 331
  • 3
  • 6