Jump to content
Changes to the Jaspersoft community edition download ×

Error calling iReport from PHP


toreay

Recommended Posts

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.1apachehtdocsvtigerCRMiReportTest3.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.1apachehtdocsvtigerCRMiReportTest3.php(101): java_InternalException->getCause() #8 {main}]

 

I have included the necessary PATH and CLASSPATH, with jasperreport-5.6.0.jar in the ~WEB-INFlib. 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

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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-ultimate-guide and this sample may help http://jasperreports.sourceforge.net/sample.reference/webapp/index.html#webapp 

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...