From: Mikael G. <mi...@oe...> - 2005-10-20 14:23:23
Attachments:
mikael.vcf
|
Hi! Having problem when using rmi with php-java-bridge-2.0.8. Trying the following php code: <?php /* * Load Java Bridge */ if (!extension_loaded('java')) { if (!(PHP_SHLIB_SUFFIX=="so" && dl('java.so'))&&!(PHP_SHLIB_SUFFIX=="dll" && dl('php_java.dll'))) { echo "java extension not installed."; exit(2); } } $here=getcwd(); java_require("$here/jpos-1.4.6.jar"); java_require("$here/myClasses.jar"); // Get an ISOMsg handle and do something with it $ISOMsg = new java("org.jpos.iso.ISOMsg"); $ISOMsg->setMTI ("0260"); $lookup = new java_class("java.rmi.Naming"); $cekrm = new java("se.certitrade.myServerRemote"); $cekrm = $lookup->lookup("//www.somedomain.net/myServer"); ?> The rmi call passes an ISOMsg object that is part of the jpos-1.4.6.jar package. The myServerRemote java looks like: package se.certitrade; import java.rmi.Remote; public interface myServerRemote extends Remote { ISOMsg sendTransaction(ISOMsg msg) throws RemoteException; } When I try to run the php file I get: java.lang.ClassNotFoundException: Unresolved external reference: java.lang.NoClassDefFoundError: org/jpos/iso/ISOMsg. -- Unable to call the method because it or one of its parameters refer to the mentioned external class which is not available in the current "java_require(<path>)" url path. Remember that all interconnected classes must be loaded with a single java_require() call and that a class must not appear in more than one java_require() call. Please check the Java Bridge log file for details. at php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1150) at php.java.bridge.Request.handleRequest(Request.java:204) at php.java.bridge.Request.handleRequests(Request.java:221) at php.java.bridge.JavaBridge.run(JavaBridge.java:233) at php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:20) Caused by: java.lang.NoClassDefFoundError: org/jpos/iso/ISOMsg . . This happens when the lookup method in the php-file is run. ISOMsg is (obviously) already instanciated and available. How do I get around this? Best regards /Mikael |
From: Jost B. <jos...@ya...> - 2005-10-20 17:20:52
|
Hi Mikael, > java_require("$here/jpos-1.4.6.jar"); > java_require("$here/myClasses.jar"); [...] > The myServerRemote java looks like: > sendTransaction(ISOMsg msg) [...] > The rmi call passes an ISOMsg object that is part of > the jpos-1.4.6.jar [...] > Unresolved external reference: java.lang.NoClassDefFoundError: org/jpos/iso/ISOMsg [...] happens when the lookup method in the php-file is run as I understand the above problem ISOMsg is not available to your classes because you haven't required it (you have required it for the bridge, but not for your classes). This behaviour is intentional, please see the tests.php4/NoClassDefFound tests. For example the server part could easily require a different version of jpos or it could only require the stub classes. Isn't it possible to require jpos for your classes, too? Does # reset the classloader once echo '<?php java_reset(); ?>' |/usr/bin/php <?php [...] java_require("jpos-1.4.6.jar"); java_require("myClasses.jar;jpos-p.x.y.jar"); [...] ?> solve the problem? If so, this means that the PHP/Java Bridge documentation is broken. I think I need a hint how to reformulate the sentence "all interconnected classes must be loaded by the same classloader". Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Mikael G. <mi...@oe...> - 2005-10-21 08:05:52
Attachments:
mikael.vcf
|
Hello Jost. Thanks for quick reply. The bridge is really good stuff, hopefully I can get i working for this app as well... Jost Boekemeier wrote: >Hi Mikael, > > > >>java_require("$here/jpos-1.4.6.jar"); >>java_require("$here/myClasses.jar"); >> >> >[...] > > >>The myServerRemote java looks like: >>sendTransaction(ISOMsg msg) >> >> >[...] > > >>The rmi call passes an ISOMsg object that is part of >>the jpos-1.4.6.jar >> >> >[...] > > >>Unresolved external reference: >> >> >java.lang.NoClassDefFoundError: org/jpos/iso/ISOMsg >[...] happens when the lookup method in the php-file >is run > >as I understand the above problem ISOMsg is not >available to your classes because you haven't required >it (you have required it for the bridge, but not for >your classes). > >This behaviour is intentional, please see the >tests.php4/NoClassDefFound tests. For example the >server part could easily require a different version >of jpos or it could only require the stub classes. > >Isn't it possible to require jpos for your classes, >too? > > Actually I do require jpos for my classes - in ServerRemote the import where hidden by eclipse - they actually look like: package se.certitrade; import java.rmi.Remote; import java.rmi.RemoteException; import org.jpos.iso.ISOMsg; public interface ServerRemote extends Remote { . . Sorry about that. The server side also requires jpos ISOMsg and all other used jpos classes (all from the same version of jpos). >Does > ># reset the classloader once >echo '<?php java_reset(); ?>' |/usr/bin/php > ><?php >[...] >java_require("jpos-1.4.6.jar"); >java_require("myClasses.jar;jpos-p.x.y.jar"); >[...] >?> > >solve the problem? > > Nope, sorry made no difference, maybe something I've missed or don't understand here?........... Regards /Mikael |
From: Jost B. <jos...@ya...> - 2005-10-21 16:57:10
|
Hi Mikael, > Actually I do require jpos for my classes - in > ServerRemote the import import != java_require. the import is only syntactic shugar for the java compiler. The NoClassDefFoundError means that you have used import at compile-time but you have failed to add the classes at run-time. > The server side also requires jpos ISOMsg java_require("jpos.jar") doesn't magically make the classes within jpos available to your own classes. It makes them available to the PHP/Java Bridge, but not to the classes within myClasses.jar. The noClassDefFound2.php test checks this pattern, please see http://cvs.sourceforge.net/viewcvs.py/php-java-bridge/php-java-bridge/tests.php4/noClassDefFound1.php?rev=1.2&view=markup The pattern java_reset(); java_require("foo.jar"); java_require("my.jar"); must fail because foo is not available to my, but java_reset(); java_require("foo.jar;my.jar"); must succeed. > Nope, sorry made no difference Can you please set java.log_level=4, re-start the bridge, run the test and attach the log to a ticket? Please see http://sourceforge.net/tracker/?func=add&group_id=117793&atid=679233 Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Mikael G. <mi...@oe...> - 2005-10-24 19:50:01
Attachments:
mikael.vcf
|
Jost Boekemeier wrote: >java_require("myClasses.jar;jpos-p.x.y.jar"); > >solve the problem? > > Yes it solved the problem! Sometimes it's so hard to see obvious things....sigh... Thanks a million for pointing this out. The bridge is really a cool tool. Regards /Mikael |