Highlighted
Absent Member.
Absent Member.
6059 views

JVM COBOL calling java MQ classes

In Visual COBOL 2.1 for Eclipse, I'm trying to build a JVM application that I would want to deploy on z/Linux, so created a  COBOL JVM Class, coded the statement  $set ilusing"com.ibm.mq", add a JAR to the JVM Build Path in which package com.ibm.mq exists, then wrote the line of code  

set mqmanager to new MQQueueManager(qMgrName)  in a method within the class. I cannot get the compiler/builder to recognize MQQueueManager as a class that I can access. I get the error message "COBCH0845S Unknown class 'MQQueueManager' "

I added some ilusing statements for java.lang, and can quite happily access classes like Integer.

I'm very new to this environment including object COBOL, but I think I've set up everything I should to have my class invoke a java class.

So, what am I doing wrong.

 

 

0 Likes
11 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: JVM COBOL calling java MQ classes

From what I remember about MQ's Java support it also requires PATH/LIBPATH to be setup for it to work,

when you added the .jar file to CLASSPATH or the eclipse build path did you also setup the native

library path too?

re: www-01.ibm.com/.../docview.wss

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: JVM COBOL calling java MQ classes

Just to confirm. Can I set the CLASSPATH within Eclipse or in a Command Window?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: JVM COBOL calling java MQ classes

I set up the CLASSPATH environment variable per the IBM info. But to no avail. Eclipse/Visual COBOL is finding the class in the package within the .jar file. I would just like to write the program and compile it. Then I can promote getting Visual COBOL as a full product in house. I really do not want to write the whole program/process in Java, but if I can't access the MQ class library I will have to. One thing of interest, if I go into the Java perspective in Eclipse, I can see the .jar file, the packages in it and the drill down to the classes and methods!!!!

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: JVM COBOL calling java MQ classes

Sorry meant to say Eclipse/Visual COBOL is NOT finding the class

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: JVM COBOL calling java MQ classes

I can get the following to compile without a problem in JVM COBOL on Windows by including the com.ibm.mq.jar in the build path.

    $set ilusing(com.ibm.mq)
      program-id. callMQ as "callMQ".
      data division.
      working-storage section.
      01 mqinstance type MQQueueManager.
      procedure division.

          set mqinstance to new type MQQueueManager("test")
          goback.

      end program callMQ.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: JVM COBOL calling java MQ classes

It would seem that I'm basically doing the same as the example code above, but still not working.

Following is my code:

     $set ilusing"java.io"

     $set ilusing"java.lang"

     $set ilusing"javax.jms"

     $set ilusing"com.microfocus.cobol.program"

     $set ilusing"com.ibm.mq"

      class-id hoganfeeds.BuildCallstoNSPforHoganData public.

     *working-storage section.

      01 working-variables.

          05  sleep-period                binary-long  value 5000.

          05  qMgrName                    pic x(8) value "REQMGR".  

          05  queue-options               binary-long.

      copy "javatypes.cpy".              

      method-id main public static.

      01 hoganfileprocessor type BuildCallstoNSPforHoganData.

      procedure division using by value args as string occurs any.

          set hoganfileprocessor to type

                  BuildCallstoNSPforHoganData::createFileProcessor

          invoke hoganfileprocessor::start

      end method.      

      method-id openqueuemgr private.

      01 mqmanager    type MQQueueManager.

      procedure division.

          set mqmanager to new MQQueueManager(qMgrName)

      end method.    

      method-id start public.

          call "CBL_THREAD_SLEEP" using by value sleep-period.

          invoke self::openqueuemgr.

      end method.

I added an External JAR that contains the package com.ibm.mq. The info on the build path screen is

mq-7.0.1.3.jar - C:\Documents and Settings\bundaya\IBM\mqc75

In the Java perspective for the project I have

JRE System Library

COBOL JVM Runtime System

Reference Libraries

     mq-7.0.1.3.jar

           com.ibm.mq  (with package symbol next to it)

                  MQQueueManager.class

                  MQQueueManagerFactory.class

So Eclipse is seeing the class in drilldown but JVM Cobol is not.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: JVM COBOL calling java MQ classes

I copied your source into a new project and commented out a couple lines that referenced methods that you didn't show and added com.ibm.mq.jar to the external JARs of the JVM Build path and it works fine.

One thing that I noticed though is that if I added the reference JAR file when the project was first created then it was not being saved.

Right click on your project and select Properties.

Under Micro Focus COBOL-->JVM Build Path tab click on Libraries-->Add External Jars and select the com.ibm.mq.jar file. Mine is under C:\Program Files (x86)\IBM\Websphere MQ\java\lib.

My project looks like:

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: JVM COBOL calling java MQ classes

Everything looks very similar, the difference I believe is that I received the Websphere stuff from another member of staff in a .zip file that extracted out to a .jar file called mq-7.0.1.3.jar. Within that jar file is the package com.ibm.mq containing the classes.   I do not have a com.ibm.mq.jar file.

Should I be coding my "ilusing" statement differently?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: JVM COBOL calling java MQ classes

I am not sure exactly what this mq-7.0.1.3.jar file is.

It appears to be a fixpack for mq 7.0.

You should probably check with IBM to find out what jar file you should be using as the com.ibm.mq.jar file works fine for me.

Can you reference the MQQueueManager class from a Java program in Eclipse using the same jar file?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: JVM COBOL calling java MQ classes

Chris, I built the following small Java program within the project I'm writing my COBOL program, and while I'm getting a compiler error, the error would indicate that Eclispe is finding the class library in the .jar file I have. The code is as follows:

package hoganfeeds;

import com.ibm.mq.*;

public class TestAccesstoMQ {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

MQQueueManager queueManager=new MQQueueManager("REMQ");

}

}

The error message is now

"The constructor MQQueueManager(String) refers to the missing type MQException"

suggesting that the code needs a try/catch pair, but clearly locating the class.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: JVM COBOL calling java MQ classes

I believe at this point that it would be helpful if you submitted a support incident with Customer Care for this as we will probably need to exchange files or do a Live Meeting with you.

I am not an expert in the area of MQ and Websphere but from my limited testing it worked correctly for me using an eval copy of MQ that I downloaded from the IBM web site.

Perhaps you could try this for a test and download the latest MQ for Java from IBM and try with the com.ibm.mq.jar package that is installed with it?

Thanks.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.