From: SQUILLACE M. <msq...@so...> - 2005-09-21 09:44:06
|
Jost, Thank you for the reply. >> When installing the client Java bindings, WebSphere >> puts them in /opt/mqm/java/lib > Loading them shouldn't be a problem if the application > server knows about this directory and automatically > adds its content to the classpath. If not, then one > must find another way to load the libraries. I am not using an application server, but simply start the php-java-bridge as a service. I wrote WebSphere but meant the WebSphere MQ installation scripts. Another goal of my tests is to define the lightest environment to install on a PHP webserver to enable Java class invocation. > The recommended way to load libraries is to install > them as name-version.jar in /usr/share/java or one of > its sub directories and then require them with the > name and version number. Good point, I wouldn't mind adding a java_require() statement in order to maintain a cleaner environment. This is not so easy to do in this instance, since all the samples in the WebSphere documentation assume a classpath is set as specified in the installation notes, and the product's jar files are clearly interlinked: I tried to java_require() only the libraries needed by the classes I was using in my sample and kept getting errors, that went away as soon as I created the symbolic links in /usr/share/java. I believe one should java_require() ALL the WebSphere MQ jars in each PHP script; a more elegant approach could be to centralize the java_require() statement in a PHP include file, so that when a next WebSphere MQ release adds a new jar one needs only modify one file. >> Apparently the bridge keeps converting the second >> argument (an integer) >> to java.lang.Long while the method mandates an int. > Does it require an int or does it require a > java.lang.Integer? I think this is a bug in the PHP documentation which talks about "integer"=20 > and "float" even though these are long and double. It requires an int. In one of several attempts I called the method with an object of class java.lang.Integer and the error message simply became: Fatal error: Uncaught [class java.lang.Exception: java.lang.Exception: Invoke failed: [class com.ibm.mq.MQQueueManager]->accessQueue(class java.lang.String, class java.lang.Integer). Cause: java.lang.IllegalArgumentException: java.lang.ClassCastException@1a786c3] From a brief examination of JavaBridge.java (remember I don't speak fluent Java at all) I seem to understand the conversion to int is not implemented; reading the JSR 223 conversely shows it should be, since the bridge has to "adapt" the script request to the "most closely matching" method argument list. Bye, Massimo=20 |
From: Jost B. <jos...@ya...> - 2005-09-21 18:28:22
|
Hi, > I believe one should java_require() ALL the > WebSphere MQ jars in each > PHP script What about extending java_require() so that it can load jar files from a given directory? In the meantime it might be possible to call initClassLoader("dir") overriding the default phpConfigDir. Please see http://cvs.sourceforge.net/viewcvs.py/*checkout*/php-java-bridge/php-java-bridge/server/doc/php/java/bridge/DynamicJavaBridgeClassLoader.html#initClassLoader(java.lang.String) > >> Apparently the bridge keeps converting the second > >> argument (an integer) > >> to java.lang.Long while the method mandates an > int. > It requires an int. [...] > accessQueue(class > java.lang.String, class java.lang.Integer). Cause: > java.lang.IllegalArgumentException: > java.lang.ClassCastException@1a786c3] If it requires an int then I think we wouldn't see the ClassCastException. php ints (which are actually longs) are transferred as <L v="longval"/>. coerce can convert the longval into a int, but it cannot convert it into a java.lang.Integer. > implemented; reading the JSR 223 conversely shows it > should be, since > the bridge has to "adapt" the script request to the > "most closely > matching" method argument list. "If members matching the name, type and arguments specified in the script are found, the arguments may be converted to the exact types in the best matching member's signature and the member may be invoked." As I understand 3.3.4 we may decide if we call the method and we may or may not coerce the argument to the required type. IMHO the above sentence does not say that we must not call the method (and throw a NoSuchMethodException) if the arguments cannot be coerced. In general we cannot auto-convert a long to a java.lang.Integer without altering the value. If such a conversion is necessary I think the user must do this, for example by calling "new java("java.lang.Integer", $phpLongValue);" Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Ben G. <be...@ja...> - 2005-09-23 16:39:17
Attachments:
signature.asc
|
Jost Boekemeier wrote: > > In general we cannot auto-convert a long to a > java.lang.Integer without altering the value. If such > a conversion is necessary I think the user must do > this, for example by calling "new > java("java.lang.Integer", $phpLongValue);" That's what I was trying to get at - if int<->Integer conversion works, then it is easy to instantiate an Integer from PHP code and pass that to your Java method. There would be no need for the "php ints are java longs" flag. -- Ben Gollmer Jatosoft LLC |
From: Jost B. <jos...@ya...> - 2005-09-25 11:22:30
|
Hi Ben, > That's what I was trying to get at - if > int<->Integer conversion works, how should this work when the parameter doesn't have any type information? $hash->put(3); should the 3 be converted into an Integer or a Long? Currently it's a Long (for ext/java compatibility). Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Ben G. <be...@ja...> - 2005-09-26 17:58:51
Attachments:
signature.asc
|
Jost Boekemeier wrote: > Hi Ben, > > >>That's what I was trying to get at - if >>int<->Integer conversion works, > > > how should this work when the parameter doesn't have > any type information? > > $hash->put(3); > > should the 3 be converted into an Integer or a Long? > > Currently it's a Long (for ext/java compatibility). > So if you wanted an Integer, couldn't you just do $i = new java.lang.Integer(3); $hash->put($i); Or doesn't that work? -- Ben |
From: Ben G. <be...@ja...> - 2005-09-22 18:44:10
Attachments:
signature.asc
|
SQUILLACE MASSIMO wrote: > It requires an int. In one of several attempts I called the method > with an object of class java.lang.Integer and the error message > simply became: > > Fatal error: Uncaught [class java.lang.Exception: > java.lang.Exception: Invoke failed: [class > com.ibm.mq.MQQueueManager]->accessQueue(class java.lang.String, class > java.lang.Integer). Cause: java.lang.IllegalArgumentException: > java.lang.ClassCastException@1a786c3] Shouldn't java autobox/autounbox Integer to int and vice versa? It will if you are using java 1.5 at least. -- Ben Gollmer Jatosoft LLC |