ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Null value while accessing input message tree in Javacompute

Post new topic  Reply to topic
 Null value while accessing input message tree in Javacompute « View previous topic :: View next topic » 
Author Message
emiddleware
PostPosted: Thu Dec 04, 2014 11:30 pm    Post subject: Null value while accessing input message tree in Javacompute Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 120

Hi,

I am using MQ v7.1 , WMB v8.0.0.0.0 on Windows Ultimate environment.
My xml structure data is
Code:
<Participant>
    <External_Id>
        P000064
   </External_Id>
</Participant>


I chose , XMLNSC as Input message parsing , and Parsing Timing as "Immediate " , in the input node properties.

I want to access the value of "External_Id" element.
I use the code in JCN as
Code:
 String strEx = "";
 strEx = inMessage.getRootElement().getFirstElementByPath("/Participant/External_Id").getValueAsString();
         System.out.println("Value of External_Id == >" +strEx);


But I get Null pointer exception ..

I even tried this statement :

Code:
MbElement root = contact admin.getMessage().getRootElement();
 MbElement externalid = root.getLastChild().getFirstChild().getFirstChild();
            String strex = "";
            strex = externalid.getValueAsString();
           System.out.println("print the value of external id (Assembly) === >>"+strex);

I am still getting null value ...

I refered the following links :

http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac30330_.htm%23ac30330_

http://mqseries.net/phpBB/viewtopic.php?t=55253&sid=daca975983d2a094dd4d1ca4ef498a7a


Please let me know where I am missing . Your inputs will help me. Thanks.
_________________
Best Regards,
E-MiddleWare
Back to top
View user's profile Send private message Send e-mail
emiddleware
PostPosted: Fri Dec 05, 2014 12:16 am    Post subject: Null value while accessing input message tree in Javacomput Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 120

I tried
Code:
MbElement root = contact admin.getMessage().getRootElement();
            MbElement externalid = root.getLastChild().getFirstChild().getFirstChild();
            String strex = "";
            strex = externalid.getValueAsString();
           System.out.println("print the value of external id (Assembly) === >>"+strex);
           MbElement externalid1 = inRoot.getLastChild().getFirstChild().getFirstChild();
           String strex1 = "";
           strex1 = externalid1.getValueAsString();
           System.out.println("print the value of external id (Message) === >>"+strex1);


Still I am getting null value
_________________
Best Regards,
E-MiddleWare
Back to top
View user's profile Send private message Send e-mail
emiddleware
PostPosted: Fri Dec 05, 2014 12:20 am    Post subject: Null value while accessing input message tree in Javacomput Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 120

Please ignore above message .

I tried the below code


Code:
MbMessage inMessage = contact admin.getMessage();
                           MbMessage outMessage = new MbMessage(inMessage);
            MbElement inRoot = inMessage.getRootElement().getLastChild();
            MbElement root = contact admin.getMessage().getRootElement();
            MbElement externalid = root.getLastChild().getFirstChild().getFirstChild();
            String strex = "";
            strex = externalid.getValueAsString();
           System.out.println("print the value of external id (Assembly) === >>"+strex);
           MbElement externalid1 = inRoot.getLastChild().getFirstChild().getFirstChild();
           String strex1 = "";
           strex1 = externalid1.getValueAsString();
           System.out.println("print the value of external id (Message) === >>"+strex1);

_________________
Best Regards,
E-MiddleWare
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri Dec 05, 2014 5:50 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You can use usertrace to see how the java code executes.

Your last set of code assumes that the field you want is specifically in the position in the tree you're accessing, rather than finding it by name which the first set of code did.

You should be able to use the getFirstElementByPath just fine, as long as you make sure you know where you're starting from and what the path has to look like from that point.

A trace node output of the tree should help you resolve path issues.
Back to top
View user's profile Send private message
emiddleware
PostPosted: Sun Dec 07, 2014 11:22 pm    Post subject: Null value while accessing input message tree in Javacompute Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 120

Hi All ,
I see a strange behavior here.

While accessing the tree elements, and then print the value by using the statement
Code:
valueString = (String)valueElement.getValue(); , I was able to print the value and see the value in Broker console as  Value of External_Id == >P000282.

Strangely , When I again ran today, the same code, only different value, I get a null value exception....
In Event viewer, I always see error stuck at the statement
Code:
valueString = (String)valueElement.getValue(); or
valueString = valueElement.getValueAsString();


Mqjeff : I applied trace node.

Code:
In Trace - After MQInput node and before JCN
(0x01000000:Folder):XMLNSC     = ( ['xmlnsc' : 0xa1401b0]
    (0x01000000:Folder):Participant = (
      (0x03000000:PCDataField):External_Id = 'P000064' (CHARACTER)
    )
  )
Out Trace  - After JCN node , I see the values as
(0x01000000:Folder   ):XMLNSC                    = ( ['xmlnsc' : 0xa123410]
    (0x01000000:Folder):Participant = (
      (0x03000000:PCDataField):External_Id = 'P000064' (CHARACTER)
    )
  )
  (0x01000000:Folder   ):XMLNSC                    = ( ['xmlnsc' : 0xa07e9a0]
    (0x03000000:PCDataField):Business_Name = 'MicroAire' (CHARACTER)
  )
  (0x03000000:NameValue):Col1Value - Business_Name = 'MicroAire' (CHARACTER)
)

My message flow is able to retrieve Business_Name from DB2 based on External_Id.
But I don't understand why the value is not printing in Broker console ???
The java runtime is jre7 in my local system.
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)

Kindly help me with your inputs . Your inputs can help me towards a right direction. Thanks.
_________________
Best Regards,
E-MiddleWare
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Dec 08, 2014 3:04 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

A coupe of tips:
- when posting code or trace outputs in this forum, please use the [c ode] tags to make your posts readable.
- I never use System.out.println() statements to debug a message flow. You can set the Java debug port and then attach the Eclipse Java debugger to your message flow. See online for details.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
emiddleware
PostPosted: Mon Dec 08, 2014 3:44 am    Post subject: Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 120

kimbert wrote:
A coupe of tips:
- when posting code or trace outputs in this forum, please use the [c ode] tags to make your posts readable.
- I never use System.out.println() statements to debug a message flow. You can set the Java debug port and then attach the Eclipse Java debugger to your message flow. See online for details.


Thanks for your suggestions , Kimbert.
I did not get [c ode]. Could you elaborate ?
_________________
Best Regards,
E-MiddleWare
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Dec 08, 2014 5:04 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You can format your posts using the buttons that are located just above the edit window.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Null value while accessing input message tree in Javacompute
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.