0

I am having a trouble on checking null value from a Java Method component in Tibco ActiveMatrix process.

Basically, I have a Java Method component invoking java to get a billing account, if the return is null, I would like to log the searching criteria - billing account id; otherwise, I will map the object to be XML content...

The problem is while using the following in 'XPath' to check the null object in a transition (Success with condition):

  • empty($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue
  • count($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue)= 0
  • string-length($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue) = 0

'$Get-BA-Details' is the Java Method component.

they all return 'false', and then try to map the java object to be XML content, which results in error while billing account is not found.

Could anyone shed some lights?

Thanks a lot!

Tom Howard
  • 6,516
  • 35
  • 58
tom.au
  • 21
  • 1
  • 3

2 Answers2

0

Try this:

$Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue=""

  • Welcome to SO. Answers, especially answers with code, should be more substantial. Explain your code a little. Why should the OP (or anyone who reads this in the future) "try this"? What is the code doing? – psubsee2003 Oct 05 '12 at 08:18
  • Hi Ecuevas, thanks a lot for your answer. I've tried and it didn't work. I think: $Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue="" is as same as string-length(...) one. – tom.au Oct 07 '12 at 23:03
0

From what I can tell you cannot check if the return from a Java Method activity is null using XPath. Instead you can create a Java Code activity that takes an ObjectReference as an input parameters and provides a boolean as an output parameter. You can then use code like to following to check if the object is null (object is the input parameter and isnull is the output parameter):

isnull = object == null; 

I have created BWUnit tests in the for this in the latest snapshot of BWUnit, which you can download from http://windyroad.org/software/bwunit/download/BWUnit-11.2.zip

The tests are located at StackOverflow/UnitTestSuite/JavaMethodNullTestCase in the simple example, which is found in Examples/Simple within the download.

Tom Howard
  • 6,516
  • 35
  • 58
  • Mate, thanks a lot! Haven't been here for a while for tackling other stuffs. I would like to give it a try... Thanks again! – tom.au Oct 31 '12 at 00:51