Author |
Message
|
wolstek |
Posted: Thu Dec 16, 2004 7:28 am Post subject: Switch Sample Java Plugin. Can't get it to run on v5 |
|
|
Acolyte
Joined: 25 Jun 2001 Posts: 52 Location: Bristol, UK
|
I have seen the various forum items on this but so far none of the suggestionsseems to help
I am trying to implement the Switch sample java plugin on WBIMB v5 (Windows) but each time I deploy a message flow containing the node I get the message
Quote: |
BIP2241E: LIL not found for message flow node type 'SwitchNode' in message flow 'RunSampleSwitch'. |
I can't help thinking that I am missing something obvious.
Many thanks
I renamed the JavaSwitchPluginNode.java file to SwitchNode.java and updated it to reflect the class name. Then compiled on a command line with
Code: |
cd mydirectory
javac com/ibm/callejb/nodes/CallEJBNode.java
jar -cvf CallEJBNode.jar com/ibm/callejb/nodes
|
The resulting Switchnode.jar file has been copied to install_root\jplugin (broker restarted) and looks like
C:\Documents and Settings\Administrator\My Documents\$DWP\SampleSwitch>jar -tvf SwitchNode.jar
0 Sat Apr 16 14:59:14 BST 2005 META-INF/
62 Sat Apr 16 14:59:14 BST 2005 META-INF/MANIFEST.MF
0 Sat Apr 16 13:05:02 BST 2005 com/ibm/samples/nodes/
3256 Sat Apr 16 14:59:12 BST 2005 com/ibm/samples/nodes/SwitchNode.class
5608 Sat Apr 16 13:00:54 BST 2005 com/ibm/samples/nodes/SwitchNode.java
[/code]
The classpath includes SwitchNode.jar =
Code: |
C:\Documents and Settings\Administrator\My Documents\$DWP\SampleSwitch>echo %CLASSPATH%
C:\Program Files\IBM\WEBSPH~2\jplugin\SwitchNode.jar;=C:\Program Files\IBM\WEBSPH~2\classes\jplugin.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\providerutil.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;C:\Program Files\IBM\WebSphereMQ\Java\lib\ldap.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jta.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jndi.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\connector.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\fscontext.jar;C:\Program Files\IBM\WebSphereMQ\Java\lib\com.ibm.mq.jar;.;C:\PROGRA~1\SQLLIB\java\db2java.zip;C:\PROGRA~1\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\SQLLIB\java\sqlj.zip;C:\PROGRA~1\SQLLIB\java\db2jcc_license_cisuz.jar;C:\PROGRA~1\SQLLIB\java\db2jcc_license_cu.jar;C:\PROGRA~1\SQLLIB\bin;C:\PROGRA~1\SQLLIB\java\common.jar
|
The code for SwitchNode.java is
[code]
/*
* Sample program for use with Product 5648-C63
* (C) COPYRIGHT International Business Machines Corp., 1999, 2001
* All Rights Reserved * Licensed Materials - Property of IBM
*
* This sample program is provided AS IS and may be used, executed,
* copied and modified without royalty payment by customer
*
* (a) for its own instruction and study,
* (b) in order to develop applications designed to run with an IBM
* WebSphere product, either for customer's own internal use or for
* redistribution by customer, as part of such an application, in
* customer's own products.
*/
package com.ibm.jsamples;
import com.ibm.broker.plugin.*;
import java.io.*;
/**
* 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 = "";
String _nodeTraceOutfile = "";
PrintWriter traceWriter = null;
/**
* 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 "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());
if(traceWriter != null) {
traceWriter.println("Element = " + switchElement.getName());
traceWriter.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.
if(_nodeTraceSetting.equals("debug") && traceWriter != null) {
traceWriter.println("Propagating to terminal: " + terminalName);
traceWriter.flush();
}
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;
if(traceWriter != null) {
traceWriter.println("Attribute nodeTraceSetting set to: " + _nodeTraceSetting);
}
}
public String getNodeTraceOutfile()
{
return _nodeTraceOutfile;
}
public void setNodeTraceOutfile(String nodeTraceOutfile)
{
_nodeTraceOutfile = nodeTraceOutfile;
if(traceWriter != null) {
traceWriter.close();
traceWriter =null;
}
try {
traceWriter = new PrintWriter(new FileWriter(nodeTraceOutfile));
if(_nodeTraceSetting.equals("debug") && traceWriter != null) {
traceWriter.println("Attribute nodeTraceOutfile set to: " + nodeTraceOutfile);
traceWriter.flush();
}
}
catch(IOException e) {
System.out.println("Trace file could not be set: " + e);
}
}
/* The following method is used to close the trace output file handle.
*/
public void onDelete()
{
if( traceWriter != null) {
traceWriter.close();
traceWriter = null;
}
}
} |
|
Back to top |
|
 |
wolstek |
Posted: Thu Dec 16, 2004 7:30 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2001 Posts: 52 Location: Bristol, UK
|
sorry compile code should have read
Code: |
javac com/ibm/samples/nodes/SwitchNode.java
jar -cvf SwitchNode.jar com/ibm/samples/nodes
|
|
|
Back to top |
|
 |
JT |
Posted: Thu Dec 16, 2004 7:53 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
|
Back to top |
|
 |
wolstek |
Posted: Fri Dec 17, 2004 4:16 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2001 Posts: 52 Location: Bristol, UK
|
I have solved this
First
by removing the package statement and placing the SwitchNode.java in the root directory and not com\ibm\samples\nodes. The jar file therefore does not refer to com/ibm/samples/nodes. Clearly my understanding of how java directory works is not up to scratch.
Second correcting the file path. The package stated com.ibm.jsamples whereas I had put the *.java file in com\ibm\samples\nodes
Thanks for your attention |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Dec 17, 2004 6:12 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Package hierarchies have to be matched by directory structure.
So, if you have a class in a package named "com.example.java.plugins.application", then you need to put the .class file in /com/example/java/plugins/application in the jar file. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vedantpatil |
Posted: Tue Jun 21, 2005 4:07 am Post subject: Not able to see user defined java node in workbench |
|
|
Novice
Joined: 10 Mar 2005 Posts: 19
|
I am new to userdefined nodes.
I have used same java code SwithNode.java given above, careated jar file and put the jar file in install_root\jplugin dir. restarted the broker.
when i open the toolkit i am not able to see the node.
Is there any other procedure i am missing?
Can anybody help me out.
Thanks
VP |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jun 21, 2005 6:05 am Post subject: Re: Not able to see user defined java node in workbench |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
|