SOA / Web Services / Java

A Technology Blog

ClassNotFOundException? – Command to find the required jar

Posted by Vivek on February 2, 2015

It is irritating when one gets ClassNotFoundException. One can go and find the jar and add it to the classpath to resolve the problem. Jars can be searched on sites like However, sometimes jars are within the system and only thing needed to fix the problem is to set the classpath appropriately. Here is the unix command to find the jar:
$ find . -name “*.jar” -print -exec jar -tf ‘{}’ \; | grep -E “jar$|String\.class”

Posted in SOA | Tagged: | Leave a Comment »

WMB – Create and View Trace Logs

Posted by Vivek on February 2, 2015

Trace logs are important when one has to find out root cause of any problem occurred during message flow execution. This post helps you understand the commands that are required:

You can create user trace by running the following command:

Start user trace:

mqsichangetrace <brokername> -u -e <egroup> -f “<Message Flow Name>” -l debug -r -c 50000

You can stop user trace with the following command:

Stop trace:

mqsichangetrace <brokername> -u -e <egroup> -f “<Message Flow Name>” -l none

Retrieve the trace log for the specified component:

mqsireadlog <brokername> -u -e <egroup> -f -o flowtrace.xml

Format XML trace file for viewing purpose:

mqsiformatlog -i flowtrace.xml -o userflowtrace.txt

Similarly, you can create service trace by executing a series of commands:

Service Level Trace:

Start trace.

mqsichangetrace <brokername> -t -e <egroup> -l debug -r -c 100000

Stop trace.

mqsichangetrace <brokername> -t -e <egroup> -l none

Retrieve the trace log for the specified component.

mqsireadlog <brokername> -t -e <egroup> -f -o flowtrace.xml

Format the XML trace file.

mqsiformatlog -i flowtrace.xml -o serviceflowtrace.txt

The serviceflowtrace.txt will be in the current working directory

Posted in IBM Websphere Message Broker | Tagged: | Leave a Comment »

How to Stop all MQ Processes?

Posted by Vivek on October 26, 2014

1. Login as mq admin user

2. Use the endmqm command to stop all running queue managers.


3. Stop any listeners associated with the queue managers, using the

endmqlsr -m {BROKERNAME}

4. To check that you have stopped all of them, enter the following

ps -ef | grep mq

5. Check that there are no processes listed that are running command lines beginning amq or runmq. Ignore any that start with amqi.

Posted in IBM Websphere MQ | Tagged: , | Leave a Comment »

Continous Integration Tools: Which one is the best?

Posted by Vivek on July 28, 2014

Here is a snapshot of the survey conducted by infoQ on their site to figure out which continuous integration tools is widely used and has got the desired features:




Posted in SOA | Leave a Comment »

Java based integration framework

Posted by Vivek on July 8, 2014

We all know the capabilities of an ESB to enable seamless integration among hetrogeneous applications. But is it always a feasible to choose an ESB where integration is not a major challenge and where applications use common protocols? The answer is NO. Most of the companies are looking for open source options which allows them build an integration architecture using simple configuration. Two of the most commonly used frameworks are:

1. Spring Integration

  • Based on popular Spring application framework
  • Dependency Injection / Inversion of Control
  • Configured within Spring Container
  • XML / Annotation based DSL
  • Supports Spring expression language


2. Apache Camel

  • Apache Software Foundation project
  • Custom Container – Camel Context
  • Can be instantiated directly from Java method
  • Integration with Spring, Guice, OSGI

Posted in SOA | Tagged: , , , , | Leave a Comment »

Purge messages from queue using Groovy/ Java

Posted by Vivek on July 8, 2014

Purging messages is one of the common operations when working with queues.

MQI (Message Queue Interface) allows browsing/ reading the message by providing various calls (MQGET, MQOPEN etc) and options alongwith. Below is a sample code to traverse the messages in a queue and perform destructive read.


// Set the Get Message Options


MQGetMessageOptions gmo1 = new MQGetMessageOptions();


boolean msgPresent = true



                def getMsg1 = new MQMessage();                     

                getQ1.get(getMsg1, gmo1);

                gmo1.options = MQC.MQGMO_MSG_UNDER_CURSOR    

                getQ1.get(getMsg1, gmo1);



   catch(MQException e){

if (e.completionCode == 1 && e.reasonCode == MQException.MQRC_TRUNCATED_MSG_ACCEPTED)


                 // Same as expected




               msgPresent = false;




Posted in Groovy, IBM Websphere MQ, Java/J2EE | Tagged: , , | 1 Comment »

Using SOAPUi to put/get message in/from IBM MQ

Posted by Vivek on July 8, 2014

We can use HermesJMS which provides out of the box feature to communicate with any of the messaging system. It comes with both soapUI open source and pro version. However, the drawback is message will contain JMS header and the responsibility of converting JMS to native header format lies with the developer/ tester. I have used IBM MQ as messaging system and in order to avoid any transformation from JMS to MQMD, I have used groovy to put and read messages.

Add a groovy test step to get hold of the XML message to be sent

def groovyUtils = new context )

def holder = groovyUtils.getXmlHolder(“AddDiscussionBoardItem#Request”) holder.getXml()

def xml = holder.getXml()

//Connect to the queue manager

// Queue used for putting message

def propIQueue = testRunner.testCase.getProperty(“inputqueue”)

//Queue used for reading message

def propOQueue = testRunner.testCase.getProperty(“outputqueue”)

 //setting hostname

def propHostname = testRunner.testCase.getProperty(“hostname”) 

MQEnvironment.@hostname = propHostname.getValue()

 //setting port

def propPort = testRunner.testCase.getProperty(“port”)

MQEnvironment.@port = Integer.parseInt(propPort.getValue())                       

//setting Channel

def propChannel = testRunner.testCase.getProperty(“channel”)

MQEnvironment.@channel = propChannel.getValue()        

//setting Queue Manager

def propQM = testRunner.testCase.getProperty(“queuemanager”)

def queueManager = new MQQueueManager(propQM.getValue())

//Put message in queue

 def putMsg = new MQMessage();


def putQ = queueManager1.accessQueue(propIQueue.getValue(), putOpenOpts);


def pmo = new MQPutMessageOptions();

putQ.put(putMsg, pmo);


//Read message from queue

def getMsg = new MQMessage();


MQGetMessageOptions gmo=new MQGetMessageOptions();

def getQ = queueManager1.accessQueue(propOQueue.getValue(), getOpenOpts);

getQ.get(getMsg, gmo);

def response = getMsg.readString(getMsg.getMessageLength())


Posted in Groovy, IBM Websphere Message Broker, IBM Websphere MQ | Tagged: , , | 1 Comment »

Deploying BAR (Broker Archive) using ANT

Posted by Vivek on July 7, 2014

This is not very straight-forward. WMB provide mqsideploy script to deploy the BAR file but before invoking the script, you need to source the mqsiprofile batch file. mqsiprofile is not a perl script and cannot be invoked directly. On windows platform, it is present in MQSI_Home/bin folder as a batch command file (.bat). This batch file has to run before mqsideploy.exe within the same script. Create a new batch command file (deploywmb.cmd) and add the following lines:


CALL “C:\Program Files\IBM\MQSI\7.0\bin\mqsiprofile.cmd”

CALL C:\Progra~1\IBM\MQSI\7.0\bin\mqsideploy.exe -i %1 -p %2 -q %3 -b %4 -e%5 -a %6



%1 corresponds to ipaddress, %2 corresponds to port and so on and are passed from Ant script.

The batch file is called and arguments are passed from Ant script as follows:

<target name=”deploy-bar”>

<property file=”${basedir}/build-properties/config/${Env}/”/>

<property name=”bar-location” value=”${basedir}//bars//${Env}_${bar.file}.bar”/>

<echo message=”MQSI Deploy “></echo>

<exec executable=”C:\utilities\wmbbuild\deploywmb.cmd”






<arg value=”${ipaddress}” />

<arg value=”${port}” />

<arg value=”${queuemgr}” />

<arg value=”${broker}” />

<arg value=”${exegroup}” />

<arg path=”${bar-location}” />


<echo message=”Deploying Broker Archive file – ${} ” />



${Env} is the environment for which BAR is created. Example – Dev, test, UAT file is the file for storing environment specific properties. The following properties are read from file:

${ipaddress} is the name of the host of the Queue Manager

${port} is the port number of the listener

${queuemgr} is the Queue Manager name of the broker

${broker} is the broker name whose execution group is to be used for deployment

${exegroup} is the name of the execution group

${bar-location} is the location of BAR file which needs to get deployed

Posted in IBM Websphere Message Broker, IBM Websphere MQ, integration | Tagged: , , , , | Leave a Comment »

MQ JARs – Build and Deployment

Posted by Vivek on July 7, 2014

We miss most of the jars in the classpath that give classnotfoundexception during operations related to WMB. Here is the list of jars required in MQ library to enable build and deployment of message flows on execution group:




Posted in IBM Websphere Message Broker, IBM Websphere MQ | Leave a Comment »

MQOPEN options while reading/browsing MQ messages

Posted by Vivek on July 7, 2014

When using MQI, it is almost a possibility to read and browse messages. MQOPEN call precedes before accessing the messages and it is important to provide correct options before you do something with the messages.
For the options of the MQOPEN call:
v At least one of the following must be specified:
v Only one of the following is allowed:
v Only one of the following is allowed:

Posted in IBM Websphere MQ, integration | Tagged: | Leave a Comment »


Get every new post delivered to your Inbox.