I'm building a web application using symfony 2 php. And I want to generate some reports using jasperreports. I used Java Bridge and I have the Java bridge war deployed in my tomcat 7 but when I try to generate my reports I face an error.
So here is my code in my controller
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
$reportsPath ="D:/jaspertest/";
$reportFileName = "report";
$jasperReportsLib = "D:/Programmes/jasperReport/lib";
$java_library_path = '';
$handle = @opendir($jasperReportsLib);
while(($new_item = readdir($handle))!==false) {
$java_library_path .= 'file:'.$jasperReportsLib.'/'.$new_item .';';
}
java_require($java_library_path);
$sJcm = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
$report = $sJcm->compileReport($reportsPath .$reportFileName.".jrxml");
$map = new Java("java.util.HashMap");
$emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource");
$sJfm = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
$print = $sJfm->fillReport($report,$map,$emptyDataSource);
$sJem = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");
$sJem->exportReportToPdfFile($print, $reportsPath .$reportFileName.".pdf");
set_time_limit(0);
@readfile($reportsPath .$reportFileName.".pdf");// or die("problem occurs.");
$response = new Response($reportsPath .$reportFileName.".pdf");
$response->headers->set('Content-type', 'application/pdf');
$response->headers->set('Content-Disposition', 'attachement; filename=Report.pdf');
$response->headers->set('Cache-Control', 'must-revalidate');
return $response;
And here is the exception I get:
Symfony\Component\Debug\Exception\ContextErrorException: Notice: fwrite():
at n/a
in http://localhost:8080/JavaBridge/java/Java.inc line 482
at Symfony\Component\Debug\ErrorHandler->handleError('8', 'fwrite(): ', 'http://localhost:8080/JavaBridge/java/Java.inc', '482', array('data' => ''))
in line
at fwrite(resource, '')
in http://localhost:8080/JavaBridge/java/Java.inc line 482
at java_SocketChannel->fwrite('')
in http://localhost:8080/JavaBridge/java/Java.inc line 528
at java_SocketHandler->write('')
in http://localhost:8080/JavaBridge/java/Java.inc line 671
at java_HttpHandler->redirect()
in http://localhost:8080/JavaBridge/java/Java.inc line 743
at java_Protocol->redirect()
in http://localhost:8080/JavaBridge/java/Java.inc line 755
at java_Protocol->finish()
in http://localhost:8080/JavaBridge/java/Java.inc line 794
at java_Protocol->invokeEnd()
in http://localhost:8080/JavaBridge/java/Java.inc line 359
at java_Client->invokeMethod('0', 'updateJarLibraryPath', array('file:D:/Programmes/jasperReport/lib/.;file:D:/Programmes/jasperReport/lib/..;file:D:/Programmes/jasperReport/lib/jasperreports-5.6.0.jar;file:D:/Programmes/jasperReport/lib/jasperreports-applet-5.6.0.jar;file:D:/Programmes/jasperReport/lib/jasperreports-fonts-5.6.0.jar;file:D:/Programmes/jasperReport/lib/jasperreports-javaflow-5.6.0.jar;', 'c:/wamp/bin/php/php5.5.12/ext/', 'C:\wamp\www\syslife_v1\web', '.;C:\php\pear'))
in http://localhost:8080/JavaBridge/java/Java.inc line 986
at java_require('file:D:/Programmes/jasperReport/lib/.;file:D:/Programmes/jasperReport/lib/..;file:D:/Programmes/jasperReport/lib/jasperreports-5.6.0.jar;file:D:/Programmes/jasperReport/lib/jasperreports-applet-5.6.0.jar;file:D:/Programmes/jasperReport/lib/jasperreports-fonts-5.6.0.jar;file:D:/Programmes/jasperReport/lib/jasperreports-javaflow-5.6.0.jar;')
in C:\wamp\www\syslife_v1\src\MamdaIT\ComptabiliteBundle\Controller\BordereauController.php line 372
at MamdaIT\ComptabiliteBundle\Controller\BordereauController->editionDetailBordereau(object(Request), '66')
in line
at call_user_func_array(array(object(BordereauController), 'editionDetailBordereau'), array(object(Request), '66'))
in C:\wamp\www\syslife_v1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php line 144
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in C:\wamp\www\syslife_v1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php line 64
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in C:\wamp\www\syslife_v1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel.php line 69
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in C:\wamp\www\syslife_v1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php line 185
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in C:\wamp\www\syslife_v1\web\app_dev.php line 30
I looked everywhere but I couldn't find a solution, am I missing something?