From: <php...@li...> - 2006-10-15 23:49:16
|
Hullo all. Well I am slowly getting closer to converting a sample java class from our processing companies API (for credit card transactions) into a woring PHP script using php-java bridge. Thanks for all the helpful tips I received so far. I am currently stuck with an error when calling a particular method of a class from the JAR file I included at the top of my script. MY CODE ========= java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ cybsclients15.jar"); java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ cybssecurity.jar"); java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ xercesImpl.jar"); java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ xml-apis.jar"); // Set up var with the class for generating the charge request $reply_class = new JavaClass("com.cybersource.ws.client.Client"); // create new hashmap variable to use for results $reply = new JavaClass("java.util.HashMap"); $reply = java_util_hashMap(); $reply = $reply_class->runTransaction($request, $props); RESULTS ======== [o(Exception):"java.lang.Exception: Invoke failed: [c(Client)]- >runTransaction((Map)o(HashMap), (Properties)o(Properties)). Cause: java.lang.ClassNotFoundException: Unresolved external reference: java.lang.NoClassDefFoundError: com/cybersource/security/exception/ SecuritySystemException. -- Unable to call the method, see the README section "Java platform issues" for details. Responsible VM: 1.5.0_06@http://apple.com/" at: #-6 php.java.bridge.JavaBridge.getUnresolvedExternalReferenceException (JavaBridge.java:481) #-5 php.java.bridge.JavaBridge.Invoke (JavaBridge.java:1084) #-4 php.java.bridge.Request.handleRequest (Request.java:499) #0 [internal function]: Java->__call ('runTransaction', Array) #1 /Library/WebServer/Documents/cj/simapi- java-5.0.0/samples/nvp/AuthCaptureSample.php(114): JavaClass- >runTransaction(Object(JavaArray), Object(JavaArray)) #2 {main}] Looking back at the docs for the Bridge, it says that if you get a "NoClassDefFound" error it means there is another class that the current class is trying to reference or call that is missing (so the Client->runTransaction is missing something). Does this mean that the four java_require statements at the top of my PHP script do not contain the missing class? These are all the JAR files that were provided as part of this API package from our card processing company. If it means that there is some other JAR I need a java_require for, how do I go about finding what JAR I should include??? Thanks, Jon |
From: <php...@li...> - 2006-10-16 16:46:25
|
Hi again. I am replying to my own question post since a friend of mine helped me track down my NoClassDefFound problem (thanks Russell). The error is in the java_require's at the beginning of my code. I needed to use the format java_require(JAR1;JAR2;JAR3;JAR4); instead of separating the requires. There is cross calling in the classes in the 4 libraries I use so they must all be brought into the same memory space. See the following reference for full details: http://php-java-bridge.sourceforge.net/documentation/PHP-API/html/ java_8c.html#doc23 I read this before, but it didn't rally gel in my brain until I was reminded of how libraries are cached by the back-end loader. Jon On Oct 15, 2006, at 4:49 PM, php-java-bridge- us...@li... wrote: > Hullo all. > > Well I am slowly getting closer to converting a sample java class > from our processing companies API (for credit card transactions) > into a woring PHP script using php-java bridge. Thanks for all the > helpful tips I received so far. > > I am currently stuck with an error when calling a particular method > of a class from the JAR file I included at the top of my script. > > MY CODE > ========= > java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ > cybsclients15.jar"); > java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ > cybssecurity.jar"); > java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ > xercesImpl.jar"); > java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ > xml-apis.jar"); > > // Set up var with the class for generating the charge request > $reply_class = new JavaClass("com.cybersource.ws.client.Client"); > // create new hashmap variable to use for results > $reply = new JavaClass("java.util.HashMap"); > $reply = java_util_hashMap(); > $reply = $reply_class->runTransaction($request, $props); > > RESULTS > ======== > [o(Exception):"java.lang.Exception: Invoke failed: [c(Client)]- > >runTransaction((Map)o(HashMap), (Properties)o(Properties)). Cause: > java.lang.ClassNotFoundException: Unresolved external reference: > java.lang.NoClassDefFoundError: com/cybersource/security/exception/ > SecuritySystemException. -- Unable to call the method, see the > README section "Java platform issues" for details. Responsible VM: > 1.5.0_06@http://apple.com/" at: #-6 > php.java.bridge.JavaBridge.getUnresolvedExternalReferenceException > (JavaBridge.java:481) #-5 php.java.bridge.JavaBridge.Invoke > (JavaBridge.java:1084) #-4 php.java.bridge.Request.handleRequest > (Request.java:499) #0 [internal function]: Java->__call > ('runTransaction', Array) #1 /Library/WebServer/Documents/cj/simapi- > java-5.0.0/samples/nvp/AuthCaptureSample.php(114): JavaClass- > >runTransaction(Object(JavaArray), Object(JavaArray)) #2 {main}] > > > Looking back at the docs for the Bridge, it says that if you get a > "NoClassDefFound" error it means there is another class that the > current class is trying to reference or call that is missing (so > the Client->runTransaction is missing something). > > Does this mean that the four java_require statements at the top of > my PHP script do not contain the missing class? These are all the > JAR files that were provided as part of this API package from our > card processing company. > > If it means that there is some other JAR I need a java_require for, > how do I go about finding what JAR I should include??? > > Thanks, > > Jon > ---------------------------------------------------------------------- > --- > Using Tomcat but need to do more? Need to support web services, > security? > Get stuff done quickly with pre-integrated technology to make your > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel? > cmd=lnk&kid=120709&bid=263057&dat=121642______________________________ > _________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2006-10-28 18:37:50
|
Hi, please excuse the delay. > Looking back at the docs for the Bridge, it says > that if you get a > "NoClassDefFound" error it means there is another > class that the > current class is trying to reference or call that is > missing (so the > Client->runTransaction is missing something). Yes. There are proposals to add a SML style "module system" to Java and/or to add a global repository for Java classes (similar to the global assembly cache used by .NET). Until this is implemented I suggest to use the JavaBridge.war as a back end and to store all necessary java libraries to the WEB-INF/lib/ folder within the JavaBridge.war file. > Does this mean that the four java_require statements The classes loaded by one java_require statement cannot see the classes loaded by the other java_require statements, see http://php-java-bridge.sourceforge.net/documentation/PHP-API/html/java_8c.html#doc23. Merging the 4 statements into one may solve the problem. > If it means that there is some other JAR I need a > java_require for, > how do I go about finding what JAR I should > include??? Good question. From the README (http://php-java-bridge.sourceforge.net/README): Sun java platform issues ------------------------ The sun java platform does not support java "modules". This causes certain problems when running java programs. When you compile a class foo which references a class bar and ship the class foo without providing bar, the sun java platform will not complain unless the user accidentally calls a method which references the non-existing class. If this happens, a "NoClassDefFound" error is thrown. This error may not(!) indicate which class is missing and it certainly does not indicate which external library is missing. The tests.php4 folder contains two tests, noClassDefFound.php and noClassDefFound2.php which demonstrate this. To avoid this problem please document *exactly* (including the version number) which external libraries (.jar files) your software needs. If you have written software where certain methods require an optional library, please document this in the method header. If receive this error when using a Java library, this may mean the following: * an old or different JDK than expected by the library is used, for example GNU Java instead of SUN or IBM Java. * java_require("foo.jar"); java_require("bar.jar"); was used instead of java_require("foo.jar;bar.jar"); to load two interconnected libraries. * the library is simply broken or it expects certain parameters in its environment (applet parameter or system property or property file). * the library may only work within a J2EE environment from a certain vendor, for example the WebSphere Application server or the Sun Java Application server. Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |