SpiderLogic.com

SpiderLogic.com

Using Webshpere MQ from Client Applications

Al Wick

The first task is to get connected via our standalone client application. This will let us figure out what jar files are required when deploying our Webstart application.

We were able to get this working using Websphere Application Client. The application client bat file sets the classpath for our application. The classpath contained a lot of IBM jar files and property files. It also makes use of the -Xbooclasspath for setting up IBM's CORBA classes to connect to the lookup service.

Here is an example of a .bat file that uses the was5 client bat file to setup the IBM properties and uses them in the startup command.

rem ****************************
rem Setup the was5 properties
rem ****************************
call setupClient-was5

rem ***********************
rem Setup the classpath
rem ***********************

rem *************** ADD YOUR APPLICATION JARS HERE
*****************

"%JAVA_HOME%\bin\java" -Xbootclasspath/p:"%WAS_BOOTCLASSPATH%"
-Djava.ext.dirs="%WAS_EXT_DIRS%" "%SERVER_ROOT%" "%CLIENTSAS%"
<Your Main Class HERE>

There are two problems with the way the client application is configured. First, WebStart doesn't handle the -Xbootclasspath. The second problem is the setup has several references to local directories for property files as well as directories containing extra jar files. WebStart is a container that requires all the files to be part of the distribution.

In order to remove need to use the -Xbootclasspath, we can set system properties that tell the JVM to use the IBM classes for CORBA.

-Dorg.omg.CORBA.ORBClass=com.ibm.rmi.iiop.ORB 
-Dorg.omg.CORBA.ORBSingletonClass=com.ibm.rmi.corba.ORBSingleton
-Djavax.rmi.CORBA.StubClass=com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl
-Djavax.rmi.CORBA.PortableRemoteObjectClass=com.ibm.rmi.javax.rmi.PortableRemoteObject

The next step is to identify all the jar files required from the Application Client install and remove the call to the application client bat file. I have done this in the bat file below:

set WAS_HOME=C:\Program
Files\WebSphere\AppClient
set WAS_JAVA_JRE=%WAS_HOME%\java\jre

rem ******** IBM ORB **********
set
CLASSPATH=%CLASSPATH%%WAS_JAVA_JRE%/lib/ext/ibmorb.jar;%WAS_HOME%/properties;

rem ******** IBM LIB **********
set
CLASSPATH=%CLASSPATH%%WAS_HOME%/lib/messagingClient.jar;%WAS_HOME%/lib/namingclient.jar;
set CLASSPATH=%CLASSPATH%%WAS_HOME%/lib/wlmclient.jar;

rem ******** IBM JMS **********
set JMS_PATH=C:\Program Files\IBM\WebSphere MQ\Java\lib

set
CLASSPATH=%CLASSPATH%%JMS_PATH%/com.ibm.mq.jar;%JMS_PATH%/com.ibm.mqbind.jar;
set
CLASSPATH=%CLASSPATH%%JMS_PATH%/com.ibm.mqjms.jar;%JMS_PATH%/jms.jar;%JMS_PATH%/jta.jar;

The full bat file incorporating both the removal of the -Xbootclasspath and the application client setup file is listed below.

@echo off

rem ****************************
rem Setup the was5 properties
rem ****************************
set WAS_HOME=C:\Program Files\WebSphere\AppClient
set WAS_JAVA_JRE=%WAS_HOME%\java\jre

rem ****************************
rem Setup vm
rem ****************************
rem set vm=C:\j2sdk1.4.2\bin\java
set vm="%WAS_JAVA_HOME%\bin\java"

rem ****************************
rem Setup the global properties
rem ****************************
set ext=../../../3rdparty

rem ***********************
rem Setup the CLASSPATH
rem ***********************

rem ********** Your Application Jar Files Go Here ************

rem ***********************
rem IBM Jars
rem ***********************

rem ******** IBM ORB **********
set
CLASSPATH=%CLASSPATH%%WAS_JAVA_HOME%/lib/ext/ibmorb.jar;%WAS_HOME%/properties;

rem ******** IBM LIB **********
set
CLASSPATH=%CLASSPATH%%WAS_HOME%/lib/messagingClient.jar;%WAS_HOME%/lib/namingclient.jar;
set CLASSPATH=%CLASSPATH%%WAS_HOME%/lib/wlmclient.jar;

rem ******** IBM JMS **********
set JMS_PATH=C:\Program Files\IBM\WebSphere MQ\Java\lib

set
CLASSPATH=%CLASSPATH%%JMS_PATH%/com.ibm.mq.jar;%JMS_PATH%/com.ibm.mqbind.jar;
set
CLASSPATH=%CLASSPATH%%JMS_PATH%/com.ibm.mqjms.jar;%JMS_PATH%/jms.jar;%JMS_PATH%/jta.jar;

rem ****************************
rem Setup ibm classes for CORBA
rem ****************************
set ORB_OPTS=-Dorg.omg.CORBA.ORBClass=com.ibm.rmi.iiop.ORB 
set ORB_OPTS=%ORB_OPTS%
-Dorg.omg.CORBA.ORBSingletonClass=com.ibm.rmi.corba.ORBSingleton
set ORB_OPTS=%ORB_OPTS%
-Djavax.rmi.CORBA.StubClass=com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl
set ORB_OPTS=%ORB_OPTS%
-Djavax.rmi.CORBA.PortableRemoteObjectClass=com.ibm.rmi.javax.rmi.PortableRemoteObject

%vm% %ORB_OPTS% <Your Main Class Here>

Now that we have the setup for a stanalone application, we can look at setting up the application for deploying it as a WebStart application. WebStart allows us to automate the deployment and upgrading of our application on the user desktops.

Connecting using Webstart

Now that know more of the jar files and poperty files for connecting to Websphere MQ, we can proceed with converting our application to a WebStart application.

In order to get this to work, have to deploy the application client along with your application. Additionally, you have to sign each of these jar files. I am using ant to copy the files into a common directory and signing them. I found that I needed more .jar files than I had identified in the previous step.

Since all files in WebStart must be delivered in signed jar or zip files, I created an ibmproperties.zip file containing the properties files for the IBM ORB.

As part of my deployment, I wrote an ant script that copies all of the necessary .jar files into a 3rdparty directory and signs them for our application. These jar files are all part of my .war file that I deploy for my application.

I also found that the best Webstart client is the one that comes with the 1.4.2 jdk. Our application will be using the 1.4.2 jdk to run the application in, but the IBM JDK for running actually exectuting the code. This is a configuration that you can setup for each client and indicate which JDK to use in the .jnlp file for your application.

The following is the resources element from my JNLP file:

<resources>
    <j2se version="IBM-1.3">      
    <!-- IBM ORB Properties -->
    <property name="org.omg.CORBA.ORBClass" 
                  value="com.ibm.rmi.iiop.ORB"/>
    <property name="org.omg.CORBA.ORBSingletonClass" 
                  value="com.ibm.rmi.corba.ORBSingleton"/>
    <property name="javax.rmi.CORBA.StubClass" 
                 
value="com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl"/>
    <property name="javax.rmi.CORBA.PortableRemoteObjectClass"

                 
value="com.ibm.rmi.javax.rmi.PortableRemoteObject"/>
    </j2se>

    <!-- ********************* -->    
    <!-- Your Application Jars -->
    <!-- ********************* -->    

    <!-- IBM Websphere Jars -->
    <jar href="3rdparty/ecutils.jar" />
    <jar href="3rdparty/ffdc.jar" />
    <jar href="3rdparty/idl.jar" />
    <jar href="3rdparty/iwsorb.jar" />
    <jar href="3rdparty/messagingClient.jar" />
    <jar href="3rdparty/naming.jar" />
    <jar href="3rdparty/namingclient.jar" />
    <jar href="3rdparty/ras.jar" />
    <jar href="3rdparty/tx.jar" />
    <jar href="3rdparty/txPrivate.jar" />
    <jar href="3rdparty/utils.jar" />
    <jar href="3rdparty/wlmclient.jar" />
    <jar href="3rdparty/wsexception.jar" />
    
    <jar href="3rdparty/ibmorb.jar" />
    <jar href="3rdparty/ibmproperties.zip" />
    
    <!-- Websphere MQ Jars -->
    <jar href="3rdparty/com.ibm.mq.jar" />
    <jar href="3rdparty/com.ibm.mqbind.jar" />
    <jar href="3rdparty/com.ibm.mqjms.jar" />
    <jar href="3rdparty/jms.jar" />
    <jar href="3rdparty/jta.jar" />
  </resources>

We have successfully deployed our application via WebStart and been able to connect connect to Websphere MQ queues.

We have gone through the steps to configure your client application connection to the embedded Websphere MQ. We have gone through 3 different configurations, two for a standalone Swing client and one for deploying with WebStart.

References

These are references from the IBM website.
Application clients
Installing Application Clients


© 2003-2004
SpiderLogic