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 » jplugin - IBM sample node - SwitchNode

Post new topic  Reply to topic
 jplugin - IBM sample node - SwitchNode « View previous topic :: View next topic » 
Author Message
mehedi
PostPosted: Thu Mar 27, 2003 6:27 am    Post subject: jplugin - IBM sample node - SwitchNode Reply with quote

Centurion

Joined: 11 Nov 2001
Posts: 102
Location: PSTech

Hi All,
This node has been succesfully deployed on the broker.
While the plugin is processing messages it always throws this error
message (see below). I've included the source code,test data and trace before the message is input to the SwitchNode. Any suggestions ?
The broker is on an AIX machine.This is WMQI 2.1 CSD 4.
--------- Error message from java plug in

Mar 27 08:57:33 mqd01 WMQIv210[56026]: (UD01.U277Test)[4370]BIP4367E: The method
'evaluate' in Java node 'Switch1' has thrown the following exception: java.lang
.NullPointerException. : UD01.0f4d7cb9-f300-0000-0080-ee703d5442ba: /build/S210_
P/src/DataFlowEngine/PluginInterface/com_ibm_broker_plugin_CMbService.cpp: 1429:
throwableToNativeException: :




---------------------------------------- code from IBM samples
/*
* Licensed Materials - Property of IBM
* 5648-C63
* (C) Copyright IBM Corp. 1999, 2001
*/

//*package com.ibm.samples;

import com.ibm.broker.plugin.*;

/**
* Sample plugin node.
* This node propagates the incoming message to one of several output terminals
* depending on the content of the message.
* A minimal test message for this node would be:
* <data><action>change</action></data>
*/
public class SwitchNode extends MbNode implements MbNodeInterface
{
String _nodeTraceSetting;

/**
* Switch node constructor.
* This is where input and output terminal are created.
*/
public SwitchNode() throws MbException
{
createInputTerminal("in");
createOutputTerminal("add");
createOutputTerminal("change");
createOutputTerminal("delete");
createOutputTerminal("hold");
createOutputTerminal("failure");
}

/**
* This static method is called by the framework to identify this node.
* If this method is not supplied, a default name will be generated
* automatically based on the node's package/class name. In this case
* it would be 'ComIbmSamplesSwitchNode'.
*/
public static String getNodeName()
{
// return "ComIbmSwitchNode";
return "SwitchNode";
}

/**
* This evaluate message is called by the broker for each message passing
* through the flow. The message assembly is passed in with the 'assembly'
* parameter. It is possible for a node to have more than one input
* terminal. The terminal that the message has come in on is represented
* by the 'in' parameter.
*/
public void evaluate(MbMessageAssembly assembly, MbInputTerminal in)
throws MbException
{
// Navigate to the relevant syntax element in the XML message
MbElement rootElement = assembly.getMessage().getRootElement();
MbElement switchElement = rootElement.getLastChild().getFirstChild().getFirstChild();

// To aid debugging, text can be printed to stdout/stderr.
// On NT this can be viewed by selecting 'Allow sevice to interact with
// desktop' on the NT Services properties dialog.
// On Unix set the environment variable MQSI_RUN_ATTACHED=1 before
// starting the broker.
if(_nodeTraceSetting.equals("debug"))
{
System.out.println("Element = " + switchElement.getName());
System.out.println("Value = " + switchElement.getValue());
}

// Select the terminal indicated by the value of this element
String terminalName;
String elementValue = (String)switchElement.getValue();
if(elementValue.equals("add"))
terminalName = "add";
else if(elementValue.equals("change"))
terminalName = "change";
else if(elementValue.equals("delete"))
terminalName = "delete";
else if(elementValue.equals("hold"))
terminalName = "hold";
else
terminalName = "failure";

MbOutputTerminal out = getOutputTerminal(terminalName);

// Now propagate the message assembly.
// If the terminal is not attached, an exception will be thrown. The user
// can choose to handle this exception, but it is not neccessary since
// the framework will catch it and propagate the message to the failure
// terminal, or if it not attached, rethrow the exception back upstream.
out.propagate(assembly);
}

/* Attributes are defined for a node by supplying get/set methods.
* The following two methods define an attribute 'nodeTraceSetting'.
* The capitalisation follows the usual JavaBean property convention.
*/
public String getNodeTraceSetting()
{
return _nodeTraceSetting;
}

public void setNodeTraceSetting(String nodeTraceSetting)
{
_nodeTraceSetting = nodeTraceSetting;
}

}

---------------- XML data used to test this
<Request type='add'>
<CustomerType>2</CustomerType>
<CustomerAccount>01234567</CustomerAccount>
<CustomerName>Mr J.Smith</CustomerName>
<CustomerPhone>555-1234</CustomerPhone>
<CustomerAddress>15, High Street, Anytown</CustomerAddress>
</Request>

---------------Output from trace before SwitchNode(java plugin)
(
(0x1000000)Properties = (
(0x3000000)MessageSet = ''
(0x3000000)MessageType = ''
(0x3000000)MessageFormat = ''
(0x3000000)Encoding = 273
(0x3000000)CodedCharSetId = 819
(0x3000000)Transactional = TRUE
(0x3000000)Persistence = FALSE
(0x3000000)CreationTime = GMTTIMESTAMP '2003-03-27 14:15:52.710'
(0x3000000)ExpirationTime = -1
(0x3000000)Priority = 0
(0x3000000)ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x3000000)ReplyProtocol = 'MQ'
(0x3000000)Topic = NULL
)
(0x1000000)MQMD = (
(0x3000000)SourceQueue = 'TEST.MH01.INPUT1'
(0x3000000)Transactional = TRUE
(0x3000000)Encoding = 273
(0x3000000)CodedCharSetId = 819
(0x3000000)Format = 'MQSTR '
(0x3000000)Version = 2
(0x3000000)Report = 0
(0x3000000)MsgType = 8
(0x3000000)Expiry = -1
(0x3000000)Feedback = 0
(0x3000000)Priority = 0
(0x3000000)Persistence = 0
(0x3000000)MsgId = X'414d51205544303120202020202020203e495f9701b4e043'
(0x3000000)CorrelId = X'000000000000000000000000000000000000000000000000'
(0x3000000)BackoutCount = 0
(0x3000000)ReplyToQ = ' '
(0x3000000)ReplyToQMgr = 'UD01 '
(0x3000000)UserIdentifier = 'mqm '
(0x3000000)AccountingToken = X'0000000000000000000000000000000000000000000000000000000000000000'
(0x3000000)ApplIdentityData = ' '
(0x3000000)PutApplType = 28
(0x3000000)PutApplName = 'MQSeries Client for Java '
(0x3000000)PutDate = DATE '2003-03-27'
(0x3000000)PutTime = GMTTIME '14:15:52.710'
(0x3000000)ApplOriginData = ' '
(0x3000000)GroupId = X'000000000000000000000000000000000000000000000000'
(0x3000000)MsgSeqNumber = 1
(0x3000000)Offset = 0
(0x3000000)MsgFlags = 0
(0x3000000)OriginalLength = -1
)
(0x1000010)XML = (
(0x1000000)Request = (
(0x3000000)type = 'add'
(0x2000000) = '
'
(0x1000000)CustomerType = (
(0x2000000) = '2'
)
(0x2000000) = '
'
(0x1000000)CustomerAccount = (
(0x2000000) = '01234567'
)
(0x2000000) = '
'
(0x1000000)CustomerName = (
(0x2000000) = 'Mr J.Smith'
)
(0x2000000) = '
'
(0x1000000)CustomerPhone = (
(0x2000000) = '555-1234'
)
(0x2000000) = '
'
(0x1000000)CustomerAddress = (
(0x2000000) = '15, High Street, Anytown'
)
(0x2000000) = '
'
)
)
)
_________________
Thanks

Mehedi Hashir
mhashir@hotmail.com
Back to top
View user's profile Send private message MSN Messenger
jefflowrey
PostPosted: Thu Mar 27, 2003 7:04 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Somewhere in your evaluate node you are trying to use a null value as an object.

You should check all values returned from methods to see if they are null.
Particularly
Code:
String elementValue = (String)switchElement.getValue();
may not be giving you what you expect. I've seen this written as
Code:
String elementValue = switchElement.getValue().toString()
instead.
Back to top
View user's profile Send private message
yaakovd
PostPosted: Thu Mar 27, 2003 7:05 am    Post subject: Reply with quote

Partisan

Joined: 20 Jan 2003
Posts: 319
Location: Israel

Hi,

You expect that last child of your XML root element has atleast 2 levels.
It means 4 levels in XML.
But you define:
Code:

* A minimal test message for this node would be:
* <data><action>change</action></data>

Your XML should be:
Code:

<root>
   ......
   <lastchild>
       <data>
          <action>change</action>
          ......
       <data>
       ......
   </lastchild>
<root>


Code:

MbElement rootElement = assembly.getMessage().getRootElement();
MbElement switchElement = rootElement.getLastChild().getFirstChild().getFirstChild();

if(_nodeTraceSetting.equals("debug"))
{
System.out.println("Element = " + switchElement.getName());
System.out.println("Value = " + switchElement.getValue());
}

Also you must check if rootElement is not null and if switchElement is not null before you use it.
_________________
Best regards.
Yaakov
SWG, IBM Commerce, Israel
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Thu Mar 27, 2003 7:18 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Yes, he needs to check that rootElement and switchElement are not null before he uses them.

However,
Code:
MbElement switchElement = rootElement.getLastChild().getFirstChild().getFirstChild();
based on his test XML, and not on the leftover documentation from the sample switch node his is modifying, is equivalent to the following ESQL
Code:
set switchElement = InputRoot.XML.Request.(XMLAttribute)type;
which is '2 levels'.

A more direct comparison, although it might not be legal ESQL, is this
Code:
set switchElement = InputRoot.*[LAST].*[1].*[1];

The element returned by assembly.getMessage().getRootElement() is the same as the Root,InputRoot, or OutputRoot in ESQL. It's not the same as the root tag of the XML message.
Back to top
View user's profile Send private message
mehedi
PostPosted: Thu Apr 10, 2003 9:05 am    Post subject: Reply with quote

Centurion

Joined: 11 Nov 2001
Posts: 102
Location: PSTech

Yakov,

With regards to this -
"MbElement switchElement = rootElement.getLastChild().getFirstChild().getFirstChild(); "

The child for the message tree root are
(1) Properties (2) MQMD (3) Other Headers (4) Body(XML/MRM/Neon/other data) in that order.
I didn't get a chance to follow up on this
Appreciate all the help
Bye

Mehedi
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » jplugin - IBM sample node - SwitchNode
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.