Error calling iReport from PHP

0

I have created an iReport and want to call it from my PHP application. I have the following code:

 $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
 $viewer = new JavaClass("net.sf.jasperreports.view.JasperViewer");
 $report = $compileManager->compileReport(realpath("report/ProductDNList.jrxml"));
 
The first 2 lines is working fine ( as i can echo values after the 2nd line), however it return catch for the 3rd line as follow (1) and with (2) if i reflesh the page.
 
(1) ERROR generating Report:

[[o:ClassNotFoundException]:"java.lang.ClassNotFoundException: Unresolved external reference: java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ReferenceMap. -- Unable to call the method, see the README section "Java platform issues" for details and DO NOT REPORT THIS PROBLEM TO THE PHP/Java Bridge MAILING LIST!" at: #-6 php.java.bridge.JavaBridge.getUnresolvedExternalReferenceException(JavaBridge.java:422) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1055) #-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 http://192.168.1.18:8080/JavaBridge/java/Java.inc(232): java_ExceptionProxyFactory->getProxy(8, 'java.lang.Class...', 'T', true) #1 http://192.168.1.18:8080/JavaBridge/java/Java.inc(360): java_Arg->getResult(true) #2 http://192.168.1.18:8080/JavaBridge/java/Java.inc(366): java_Client->getWrappedResult(true) #3 http://192.168.1.18:8080/JavaBridge/java/Java.inc(560): java_Client->getResult() #4 http://192.168.1.18:8080/JavaBridge/java/Java.inc(1752): java_Client->invokeMethod(7, 'getCause', Array) #5 http://192.168.1.18:8080/JavaBridge/java/Java.inc(2062): java_JavaProxy->__call('getCause', Array) #6 [internal function]: java_exception->__call('getCause', Array) #7 C:\Program Files (x86)\vtigercrm-5.2.1\apache\htdocs\vtigerCRM\iReportTest3.php(101): java_InternalException->getCause() #8 {main}]

 
(2) ERROR generating Report:

[[o:ClassNotFoundException]:"java.lang.ClassNotFoundException: Unresolved external reference: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.xml.JRXmlDigesterFactory. -- Unable to call the method, see the README section "Java platform issues" for details and DO NOT REPORT THIS PROBLEM TO THE PHP/Java Bridge MAILING LIST!" at: #-6 php.java.bridge.JavaBridge.getUnresolvedExternalReferenceException(JavaBridge.java:422) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1055) #-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 http://192.168.1.18:8080/JavaBridge/java/Java.inc(232): java_ExceptionProxyFactory->getProxy(8, 'java.lang.Class...', 'T', true) #1 http://192.168.1.18:8080/JavaBridge/java/Java.inc(360): java_Arg->getResult(true) #2 http://192.168.1.18:8080/JavaBridge/java/Java.inc(366): java_Client->getWrappedResult(true) #3 http://192.168.1.18:8080/JavaBridge/java/Java.inc(560): java_Client->getResult() #4 http://192.168.1.18:8080/JavaBridge/java/Java.inc(1752): java_Client->invokeMethod(7, 'getCause', Array) #5 http://192.168.1.18:8080/JavaBridge/java/Java.inc(2062): java_JavaProxy->__call('getCause', Array) #6 [internal function]: java_exception->__call('getCause', Array) #7 C:\Program Files (x86)\vtigercrm-5.2.1\apache\htdocs\vtigerCRM\iReportTest3.php(101): java_InternalException->getCause() #8 {main}]

 

I have included the necessary PATH and CLASSPATH, with jasperreport-5.6.0.jar in the \~\WEB-INF\lib. Any idea on how can it be solved?

It's urgent, so any help on this problem would be much appreciate. Thanks in advance.

Toreay

toreay's picture
3
Joined: Apr 9 2014 - 3:06am
Last seen: 4 years 1 week ago

2 Answers:

0

Ouch.. the PHP-JAVA Bridge, a tough one to troubleshoot... and for the error text I can see how they are tired of users reporting missing dependencies to them as a bug :)

Ok, I think the answer to your question is in the error itself:
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ReferenceMap. -- Unable to call the method, see the README section "Java platform issues" for details and DO NOT REPORT THIS PROBLEM TO THE PHP/Java Bridge MAILING LIST!"

So the JVM running for the PHP/JAVA bridge was not able to find org.apache.commons in the classpath, so it looks to me that all the JR dependencies are not in your classpath, check the docs (JR Ultimate guide) http://community.jaspersoft.com/documentation/jasperreports-library-ulti... this sample may help http://jasperreports.sourceforge.net/sample.reference/webapp/index.html#...

I will recommend you to first get the report running in a pure java environment (like the sample above) so you can better check for dependencies and then move that to your PHP/JAVA bridge.

marianol's picture
4778
Joined: Sep 13 2011 - 8:04am
Last seen: 1 year 1 month ago
0

Thank you very much for your help. 

Finally I found that my missing jar file is apache-commons.jar

Put it in my classpath, then it works fine. Thanks.

toreay's picture
3
Joined: Apr 9 2014 - 3:06am
Last seen: 4 years 1 week ago
Feedback