Author |
Message
|
Gralgrathor |
Posted: Fri Feb 07, 2014 7:04 am Post subject: [SOLVED] Passing messages/elements to external java methods |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
Hi!
I've got a case of the peculiar kind of blindness that comes from staring at a bit of code for too long. I've tapped in the following construction:
A bit of Java:
Code: |
public static Long fryElement(String msg, MbElement element)
//throws MbException
{
try
{
com.kitchen.fry(element);
return new Long(1);
}
catch( Exception e )
{
return new Long(0);
}
}
|
And a bit of ESQL:
Code: |
CREATE FUNCTION fryElement(IN msg CHARACTER, IN element REFERENCE)
RETURNS INTEGER
LANGUAGE JAVA
EXTERNAL NAME "com.kitchen.fryElement";
...
DECLARE msg CHARACTER 'Now were cooking with gas!';
DECLARE xml REFERENCE TO InputRoot.XMLNSC;
DECLARE tmp INTEGER 0;
CALL fryElement(msg, xml) INTO tmp;
|
Deploys perfectly, other Java methods in the same class are resolved successfully, so this shouldn't be a problem. Now I put a message to the queue:
Code: |
( ['MQROOT' : 0x116d2c8d0]
(0x01000000:Name ):Properties = ( ['MQPROPERTYPARSER' : 0x116e741d0]
...
)
(0x01000000:Name ):MQMD = ( ['MQHMD' : 0x116d8e9b0]
...
)
(0x01000000:Folder):XMLNSC = ( ['xmlnsc' : 0x116d820d0]
(0x03000000:PCDataField):message = 'Cheese' (CHARACTER)
)
)
|
And get the following error:
Code: |
Feb 11 14:30:22 kitchen user:err|error WebSphere Broker v7004[24772854]: (BRK70_POT.MY_LITTLE_GROUP)[5798]BIP3202E: (com.kitchen.fryElement, 1.1) : An error occurred when trying to resolve the Java class or method 'com.kitchen.Pan.fryElement' which is referred to by the routine 'fryElement'. : BRK70_POT.21489507-4401-0000-0080-d60d4b31c53a: /build/S700_P/src/DataFlowEngine/ImbRdl/ImbRdlRoutine.cpp: 1235: SqlRoutine::resolveExternalJavaParameters: ComIbmComputeNode: com/kitchen/_Test#FCMComposite_1_3
Feb 11 14:30:22 kitchen user:err|error WebSphere Broker v7004[24772854]: (BRK70_POT.MY_LITTLE_GROUP)[5798]BIP2946E: The Java method 'com.kitchen.Pan.fryElement' could not be found : BRK70_POT.21489507-4401-0000-0080-d60d4b31c53a: /build/S700_P/src/DataFlowEngine/ImbRdl/ImbRdlExternalJava.cpp: 1118: ESQL2JavaMethodResolver::decodeReturnStatus: : |
I've been staring at the ESQL-to-Java mapping table for hours now, and I've read and tried suggestions from every relevant topic I could find on this board, and for the life of me I can't see where I went wrong. I would very much appreciate a second pair of eyes to see and point out to me the very obvious mistake I must be making.
Thanks!
Last edited by Gralgrathor on Tue Feb 11, 2014 6:09 am; edited 2 times in total |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Feb 07, 2014 7:19 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
An ESQL Reference variable is an MbElement[] in Java, not a plain MbElement. |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Feb 07, 2014 9:40 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
|
Back to top |
|
 |
mqjeff |
Posted: Fri Feb 07, 2014 11:29 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
dogorsy wrote: |
http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/topic/com.ibm.etools.mft.doc/ak20708_.htm |
which is exactly the page that gralgrathor has said he or she had been staring at for hours.
or did you fail to read that part? |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Feb 07, 2014 12:33 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
mqjeff wrote: |
dogorsy wrote: |
http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/topic/com.ibm.etools.mft.doc/ak20708_.htm |
which is exactly the page that gralgrathor has said he or she had been staring at for hours.
or did you fail to read that part? |
staring at is not the same as reading and trying to make sense of.
If I go to China, I can stare at the signs for ages, but if I don't know Chinese .... |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Feb 07, 2014 1:30 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
dogorsy wrote: |
mqjeff wrote: |
dogorsy wrote: |
http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/topic/com.ibm.etools.mft.doc/ak20708_.htm |
which is exactly the page that gralgrathor has said he or she had been staring at for hours.
or did you fail to read that part? |
staring at is not the same as reading and trying to make sense of.
If I go to China, I can stare at the signs for ages, but if I don't know Chinese .... |
And if someone walked up next to you and said "If you're having trouble reading those signs, it's because they're in Chinese", would you consider that helpful of them? |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Feb 07, 2014 10:25 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
mqjeff wrote: |
dogorsy wrote: |
mqjeff wrote: |
dogorsy wrote: |
http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/topic/com.ibm.etools.mft.doc/ak20708_.htm |
which is exactly the page that gralgrathor has said he or she had been staring at for hours.
or did you fail to read that part? |
staring at is not the same as reading and trying to make sense of.
If I go to China, I can stare at the signs for ages, but if I don't know Chinese .... |
And if someone walked up next to you and said "If you're having trouble reading those signs, it's because they're in Chinese", would you consider that helpful of them? |
I would consider that an insult to my intelligence. |
|
Back to top |
|
 |
mqjeff |
Posted: Sat Feb 08, 2014 8:33 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
dogorsy wrote: |
mqjeff wrote: |
dogorsy wrote: |
mqjeff wrote: |
dogorsy wrote: |
http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/topic/com.ibm.etools.mft.doc/ak20708_.htm |
which is exactly the page that gralgrathor has said he or she had been staring at for hours.
or did you fail to read that part? |
staring at is not the same as reading and trying to make sense of.
If I go to China, I can stare at the signs for ages, but if I don't know Chinese .... |
And if someone walked up next to you and said "If you're having trouble reading those signs, it's because they're in Chinese", would you consider that helpful of them? |
I would consider that an insult to my intelligence. |
But it's clearly helpful when you point gralgrathor to the same page that gralgrathor has been staring at for quite a while, then? |
|
Back to top |
|
 |
Michael Dag |
Posted: Sat Feb 08, 2014 9:14 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
so what is the missing magic here?
I don't get it either... but then again my java skills are almost non-existent...
just curious, is it something simple and very obvious??? _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
mqjeff |
Posted: Sat Feb 08, 2014 9:44 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Well, there could be some kind of deployment error, where the actual class file is not properly loaded or is loaded by the wrong classloader.
But Gralgrathor hasn't mentioned anything about what's been done, or not done, to deploy the class file.
There's otherwise not anything terribly glaringly obvious. It could be that the Long return value actually needs to be a Long[], given that it's a return value (and thus in theory an out value).
But again, unfortunately, there's not enough information about the rest of the error that occurs to say for sure. |
|
Back to top |
|
 |
Michael Dag |
Posted: Sat Feb 08, 2014 10:03 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
ok, is there a sample that does exactly this? maybe one day I'll get to it...  _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Feb 08, 2014 8:25 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
As Jeff mentioned earlier and until proven otherwise, I would treat this as an interface/method signature mismatch  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Gralgrathor |
Posted: Mon Feb 10, 2014 1:34 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
mqjeff wrote: |
An ESQL Reference variable is an MbElement[] in Java, not a plain MbElement. |
The table says
Code: |
ESQL data types Java IN data types
REFERENCE (to a message tree) com.ibm.broker.plugin.MbElement
|
To which the following applies:
The reference parameter cannot be NULL when passed into a Java method.
Which it isn't.
Anyway, I already checked the combinations of IN/INOUT, singular and arrays of MbElement (and MbMessage, etc) as parameter. They all result in the same "decodeReturnStatus" error.
mqjeff wrote: |
But Gralgrathor hasn't mentioned anything about what's been done, or not done, to deploy the class file. |
I created a Java project containing jplugin2.jar, and the JAR containing the class I wrote. I created a BAR containing those JARs and deployed it to the EG. For good measure, I added a simple method to the same class.
Code: |
public class Pan {
public static Long fryLine(String msg) { ... }
}
|
Code: |
CREATE FUNCTION fryLine(IN msg CHARACTER)
RETURNS INTEGER LANGUAGE JAVA EXTERNAL NAME "com.kitchen.Pan.fryLine";
|
Code: |
CALL fryLine('Test') INTO i;
|
And let it run.
Code: |
2014-02-10 09:05:30.840756 5719 UserTrace BIP2537I: Node 'com.kitchen.Flow.Compute': Executing statement ''SET i = fryLine('Test');'' at ('com.kitchen.mod_Flow_Compute.Main', '27.3').
2014-02-10 09:05:30.840768 5719 UserTrace BIP2538I: Node 'com.kitchen.Flow.Compute': Evaluating expression ''fryLine('Test')'' at ('com.kitchen.mod_Flow_Compute.Main', '27.8').
2014-02-10 09:05:30.861538 5719 UserTrace BIP2918I: Node 'com.kitchen.Flow.Compute': Executing Java Method ''com.kitchen.Pan.fryLine'' derived from ('com.kitchen.common.fryLine', '1.12'). Parameters passed '''Test'''. Resulting parameter values '''Test'''. Return value ''1''.
2014-02-10 09:05:30.861584 5719 UserTrace BIP2537I: Node 'com.kitchen.Flow.Compute': Executing statement ''RETURN TRUE;'' at ('com.kitchen.mod_Flow_Compute.Main', '30.3').
|
Since this ran perfectly, I conclude that the problem isn't a deployment error, but that WMB is unable to resolve the method because of a parameter type mismatch. And since the only difference in the function in my original post and the one above was the IN element REFERENCE bit and its Java equivalent, that's where the mismatch must be.
So I'm continuing to stare at the same bit of code. Still, I've had a nice and relaxing weekend, so I shouldn't complain.
Additionally, I just noticed that:
Code: |
2014-02-07 14:26:19.201928 5702 UserTrace BIP2539I: Node 'com.kitchen.Flow.Trace2': Evaluating expression ''Root'' at ('', '4.3'). This resolved to ''Root''. The result was ''ROW... Root Element Type=16777216 NameSpace='' Name='Root' Value=NULL''.
2014-02-07 14:26:19.202784 5702 UserTrace BIP4060I: Data ''
...
'' from trace node 'com.kitchen.Flow.Trace2'.
The trace node 'com.kitchen.Flow.Trace2' has output the specified trace data.
This is an information message provided by the message flow designer. The user response will be determined by the local environment.
2014-02-07 14:26:19.202816 5702 UserTrace BIP4067I: Message propagated to output terminal for trace node 'com.kitchen.Flow.Trace2'.
The trace node 'com.kitchen.Flow.Trace2' has received a message and is propagating it to any nodes connected to its output terminal.
No user action required.
2014-02-07 14:26:19.203940 5702 Error BIP2628E: Exception condition detected on input node 'com.kitchen.Flow.TEST_FLOW_IN_LQ'.
The input node 'com.kitchen.Flow.TEST_FLOW_IN_LQ' detected an error whilst processing a message. The message flow has been rolled-back and, if the message was being processed in a unit of work, it will remain on the input queue to be processed again. Following messages will indicate the cause of this exception.
Check the error messages which follow to determine why the exception was generated, and take action as described by those messages.
|
The error occurs as soon as the message exits the Trace2 node and enters the subsequent Compute node. From which I conclude that the external functions and their parameter- and return types are somehow evaluated as soon as the ESQL module that contains their CALLs is entered, right? That means that it's probably not the result of a mismatched return-value, but that it's the method definition that contains the error.
WMB makes me feel really dumb at times... |
|
Back to top |
|
 |
Gralgrathor |
Posted: Tue Feb 11, 2014 5:56 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
mqjeff wrote: |
Well, there could be some kind of deployment error, where the actual class file is not properly loaded or is loaded by the wrong classloader. |
See? It was a dumb thing after all. I'd foolishly included the jplugin in my BAR, which probably lead to the broker being unable to resolve the relevant classes. Which in turn lead to an exception in decoding the signature.
Thanks for your help, everyone! |
|
Back to top |
|
 |
|