Skip to main content

Problem:

This sample was developed with Net Express 5.0:

The sample is an 'HelloWorld' one: the service,deployed on MF Enterprise Server,

retrieves to the J2SE java client the parameter it received.

The zip files attached to this KB are:

- a file named NE-50-J2SE-HelloWorldSample.zip  which details, with screen captures, the differents steps of the operation

- a file named J2SEHelloWorld.zip which contains the code of the demonstration

You'll get in the demonstration:

AND the SERVER ( created by Net Express Interface Mapping Toolkit ) part

AND the CLIENT part (

      - generated by Net Express Interface Mapping Toolkit regards to the Java bean used

      - hand-written  client software to call the Java bean

Resolution:

==============================

1) Legacy code used for this service:

hello.CBL

       linkage section.

       01 P1 pic x(50).

       01 P2 pic x(50).

       procedure division  using P1 P2.

           move P1 to P2

           string "Hello " delimited by size p1       into p2

           exit program.

           stop run.

Hello.cbl uses 2 parameters¨P1 and P2.   

P2 is filled concatening the String ' Hello ' the content of parameter P1

==============================

2) With Net Express Interface Mapping Toolkit, creation of the service and creation of an operation  named sayHello which uses one INPUT parameter and one output parameter

==============================

3) With Net Express Interface Mapping Toolkit, setting of the Service's parameter

==============================

4) With Net Express Interface Mapping Toolkit, deploy the service to an Enterprise Server region

==============================

Rmq:

The steps described above are detailed in Net Express documentation:

http://supportline.microfocus.com/documentation/books/nx50/nx50indx.htm

'BOOK'

Interface Mapping Toolkit

'BOOK'

Java and COBOL

Chapter 2: Mapping a Java Interface and Using Resource Adapters

Using Java Beans under J2SE

Using Java Beans under J2SE

You can bypass the J2EE application server and the resource adapter, by generating a Java bean that accesses the COBOL enterprise server directly. Although this avoids the overhead of administering a J2EE application server, you lose its advantages such as transaction support.

The Java bean generated is stateless. One class is generated for the bean and other classes are generated for any data classes representing the records that are mapped.

The Java bean runs in a J2SE environment with the libraries from the J2EE server. The Java bean accesses the COBOL enterprise server directly, in an out-of-process manner. The J2SE and enterprise server run in two separate processes and they communicate through sockets.

You need to write your client software to call the Java bean.

Support for the Java bean is supplied in mfj2se.jar, which is available in the base\\bin directory.

To trace the behavior of the Java bean, use the -Dmfdebug=true switch. For example run the program myBean as follows:

java -Dmfdebug=true myBean

==============================

5) You need to write your client software to call the Java bean generated by Net Express Interface Mapping Toolkit

Sample client, named   JavaJ2SECaller.java, is delivered in the demonstration.

See it uses the bean HelloWorld created by Net Express Interface Mapping Toolkit

==============================

6) job to compile JavaJ2SECaller.java and run it

Just note this shell sets the environment variable CLASSPATH to have the Java bean HelloWorld generated by Net Express Interface Mapping Toolkit, 'on-line',

you'll have to modifty in this shell, the lines

    set JAVA_HOME="C:\\Program Files\\Java\\jdk1.5.0_08"

    set MF_HOME="C:\\MF\\NE50"    

so it matches with your environment.                                    

cl.bat

------

@echo off

cls

set JAVA_HOME="C:\\Program Files\\Java\\jdk1.5.0_08" !!! To be modified / your Environment

set MF_HOME="C:\\MF\\NE50"                                           !!! To be modified / your Environment

set NetxPrjName=J2SEHelloWorld

set ServiceName=HelloWorld

set JavaPackage=com.mypackage.HelloWorld

set PATH=%windir%;%windir%\\system32

set CLASSPATH=

set WD=�%

cd  /d %MF_HOME%\\Base\\BIN\\

call %MF_HOME%\\Base\\BIN\\createnv.bat

cd  /d %WD%

set PATH=%PATH%;%JAVA_HOME%\\bin

del   JavaJ2SECaller.class

rem or use .jar generated by IMTK deploy

rem javac -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy\\%ServiceName%.jar JavaJ2SECaller.java

rem or use DIRs generated by IMTK deploy

javac -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy                       JavaJ2SECaller.java

rem cls

rem or use .jar generated by IMTK deploy

rem java -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy\\%ServiceName%.jar JavaJ2SECaller  

rem or use DIRs generated by IMTK deploy

java -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy JavaJ2SECaller

rem use of mfdebug property

rem java -Dmfdebug=true -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy JavaJ2SECaller

==============================

7) To launch the demonstration: just launch cl.bat

==============================

8)  LOG of samples's execution:

Micro Focus Studio Version 5.001.0099 Copyright (C) 1984-2006 Micro Focus (IP) Ltd.

Java Code calling in J2SE mode a service deployed as an EJB on MF Enterprise Server

*--> String passed   to ES Service: Mr Sherlock Holmes

*--> String returned by ES Service: Hello Mr Sherlock Holmes

*--> String passed   to ES Service: Mr Watson

*--> String returned by ES Service: Hello Mr Watson

Attachments:

J2SEHelloWorld.zip

Old KB# 4334

Problem:

This sample was developed with Net Express 5.0:

The sample is an 'HelloWorld' one: the service,deployed on MF Enterprise Server,

retrieves to the J2SE java client the parameter it received.

The zip files attached to this KB are:

- a file named NE-50-J2SE-HelloWorldSample.zip  which details, with screen captures, the differents steps of the operation

- a file named J2SEHelloWorld.zip which contains the code of the demonstration

You'll get in the demonstration:

AND the SERVER ( created by Net Express Interface Mapping Toolkit ) part

AND the CLIENT part (

      - generated by Net Express Interface Mapping Toolkit regards to the Java bean used

      - hand-written  client software to call the Java bean

Resolution:

==============================

1) Legacy code used for this service:

hello.CBL

       linkage section.

       01 P1 pic x(50).

       01 P2 pic x(50).

       procedure division  using P1 P2.

           move P1 to P2

           string "Hello " delimited by size p1       into p2

           exit program.

           stop run.

Hello.cbl uses 2 parameters¨P1 and P2.   

P2 is filled concatening the String ' Hello ' the content of parameter P1

==============================

2) With Net Express Interface Mapping Toolkit, creation of the service and creation of an operation  named sayHello which uses one INPUT parameter and one output parameter

==============================

3) With Net Express Interface Mapping Toolkit, setting of the Service's parameter

==============================

4) With Net Express Interface Mapping Toolkit, deploy the service to an Enterprise Server region

==============================

Rmq:

The steps described above are detailed in Net Express documentation:

http://supportline.microfocus.com/documentation/books/nx50/nx50indx.htm

'BOOK'

Interface Mapping Toolkit

'BOOK'

Java and COBOL

Chapter 2: Mapping a Java Interface and Using Resource Adapters

Using Java Beans under J2SE

Using Java Beans under J2SE

You can bypass the J2EE application server and the resource adapter, by generating a Java bean that accesses the COBOL enterprise server directly. Although this avoids the overhead of administering a J2EE application server, you lose its advantages such as transaction support.

The Java bean generated is stateless. One class is generated for the bean and other classes are generated for any data classes representing the records that are mapped.

The Java bean runs in a J2SE environment with the libraries from the J2EE server. The Java bean accesses the COBOL enterprise server directly, in an out-of-process manner. The J2SE and enterprise server run in two separate processes and they communicate through sockets.

You need to write your client software to call the Java bean.

Support for the Java bean is supplied in mfj2se.jar, which is available in the base\\bin directory.

To trace the behavior of the Java bean, use the -Dmfdebug=true switch. For example run the program myBean as follows:

java -Dmfdebug=true myBean

==============================

5) You need to write your client software to call the Java bean generated by Net Express Interface Mapping Toolkit

Sample client, named   JavaJ2SECaller.java, is delivered in the demonstration.

See it uses the bean HelloWorld created by Net Express Interface Mapping Toolkit

==============================

6) job to compile JavaJ2SECaller.java and run it

Just note this shell sets the environment variable CLASSPATH to have the Java bean HelloWorld generated by Net Express Interface Mapping Toolkit, 'on-line',

you'll have to modifty in this shell, the lines

    set JAVA_HOME="C:\\Program Files\\Java\\jdk1.5.0_08"

    set MF_HOME="C:\\MF\\NE50"    

so it matches with your environment.                                    

cl.bat

------

@echo off

cls

set JAVA_HOME="C:\\Program Files\\Java\\jdk1.5.0_08" !!! To be modified / your Environment

set MF_HOME="C:\\MF\\NE50"                                           !!! To be modified / your Environment

set NetxPrjName=J2SEHelloWorld

set ServiceName=HelloWorld

set JavaPackage=com.mypackage.HelloWorld

set PATH=%windir%;%windir%\\system32

set CLASSPATH=

set WD=�%

cd  /d %MF_HOME%\\Base\\BIN\\

call %MF_HOME%\\Base\\BIN\\createnv.bat

cd  /d %WD%

set PATH=%PATH%;%JAVA_HOME%\\bin

del   JavaJ2SECaller.class

rem or use .jar generated by IMTK deploy

rem javac -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy\\%ServiceName%.jar JavaJ2SECaller.java

rem or use DIRs generated by IMTK deploy

javac -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy                       JavaJ2SECaller.java

rem cls

rem or use .jar generated by IMTK deploy

rem java -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy\\%ServiceName%.jar JavaJ2SECaller  

rem or use DIRs generated by IMTK deploy

java -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy JavaJ2SECaller

rem use of mfdebug property

rem java -Dmfdebug=true -classpath .;%MF_HOME%\\base\\bin\\mfj2se.jar;.\\%NetxPrjName%\\REPOS\\%ServiceName%.deploy JavaJ2SECaller

==============================

7) To launch the demonstration: just launch cl.bat

==============================

8)  LOG of samples's execution:

Micro Focus Studio Version 5.001.0099 Copyright (C) 1984-2006 Micro Focus (IP) Ltd.

Java Code calling in J2SE mode a service deployed as an EJB on MF Enterprise Server

*--> String passed   to ES Service: Mr Sherlock Holmes

*--> String returned by ES Service: Hello Mr Sherlock Holmes

*--> String passed   to ES Service: Mr Watson

*--> String returned by ES Service: Hello Mr Watson

Attachments:

J2SEHelloWorld.zip

Old KB# 4334

I have imported this program into enterprise developer and rebuild but while executing the progra, it is giving me error as below, please advise <br />

Java Code calling in J2SE mode a service deployed as an EJB on MF Enterprise Server

*--> String passed   to ES Service: Mr Sherlock Holmes

register in BINPLocalCall

TRACE:1:GUID=356b48c6-c686-1e49-9cfc-df2540e41c20 for TraceBINP2ToStdOut://CobolBean://localhost:9003

TRACE:1:removeConnectionProperty(CobolConnection)

TRACE:1:setConnectionProperty(CobolConnection,com.microfocus.cobol.connector.transport.TraceBINPToStdOut@1a183d2 (class=com.microfocus.cobol.connector.transport.TraceBINPToStdOut))

TRACE:1:-------------------------------------------------------------------

TRACE:1:--------------------- 356b48c6-c686-1e49-9cfc-df2540e41c20 ----------------------

TRACE:1:--------------------- 07.16.14  06:12:24 PM ----------------------

TRACE:1:Operation    : setbeanisinitial (internal)

TRACE:1:Return-Type  : no return-code

TRACE:1:Parameter = java.lang.Boolean=true

TRACE:1:return-code=null

TRACE:1:removeConnectionProperty(BeanInitialProperty)

TRACE:1:setConnectionProperty(BeanInitialProperty,true (class=java.lang.Boolean))

count:0

count1:2

count2:2

TRACE:1:-------------------------------------------------------------------

TRACE:1:--------------------- 356b48c6-c686-1e49-9cfc-df2540e41c20 ----------------------

TRACE:1:--------------------- 07.16.14  06:12:24 PM ----------------------

TRACE:1:Operation    : cobcall

TRACE:1:Program Name : HelloWorld.sayHello

TRACE:1:Return-Type  : no return-code

TRACE:1:total number of arguments=2

TRACE:1:argument[0] = test (by value)[className=java.lang.String][.toString()=test]

TRACE:1:argument[1] = class java.lang.String (output only)[className=java.lang.Class][.toString()=class java.lang.String]

TRACE:1:BINP Header ->

TRACE:1:Buffer size = 72 (0x48)

TRACE:1:00000000 - 4d 46 20 42 49 4e 50 00 00 00 00 01 00 00 00 38 - MF BINP........8

TRACE:1:00000010 - 00 00 00 00 00 00 00 5b 00 00 00 60 00 00 00 00 - .......[...`....

TRACE:1:00000020 - 00 00 00 24 63 37 39 64 33 39 62 66 2d 63 39 37 - ...$c79d39bf-c97

TRACE:1:00000030 - 35 2d 66 39 37 64 2d 36 64 31 65 2d 37 61 61 34 - 5-f97d-6d1e-7aa4

TRACE:1:00000040 - 62 30 30 31 64 39 39 64                         - b001d99d

TRACE:1:BINP Message ->

TRACE:1:Buffer size = 91 (0x5b)

TRACE:1:00000000 - 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 - ................

TRACE:1:00000010 - 00 00 00 13 48 65 6c 6c 6f 57 6f 72 6c 64 2e 73 - ....HelloWorld.s

TRACE:1:00000020 - 61 79 48 65 6c 6c 6f 00 00 00 00 00 00 00 01 00 - ayHello.........

TRACE:1:00000030 - 00 00 07 43 4f 42 43 41 4c 4c 00 00 00 02 00 00 - ...COBCALL......

TRACE:1:00000040 - 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 - ................

TRACE:1:00000050 - 00 00 10 00 00 00 04 74 65 73 74                - .......test

TRACE:1:BINP Reply Header ->

TRACE:1:Buffer size = 72 (0x48)

TRACE:1:00000000 - 4d 46 20 42 49 4e 50 00 00 00 00 01 00 00 00 38 - MF BINP........8

TRACE:1:00000010 - 00 00 00 00 00 00 00 21 00 00 00 60 05 26 5c 00 - .......!...`.&\\.

TRACE:1:00000020 - 00 00 00 24 63 37 39 64 33 39 62 66 2d 63 39 37 - ...$c79d39bf-c97

TRACE:1:00000030 - 35 2d 66 39 37 64 2d 36 64 31 65 2d 37 61 61 34 - 5-f97d-6d1e-7aa4

TRACE:1:00000040 - 62 30 30 31 64 39 39 64                         - b001d99d

TRACE:1:BINP Reply ->

TRACE:1:Buffer size = 33 (0x21)

TRACE:1:00000000 - 00 01 00 00 00 00 00 ad 00 00 00 00 00 00 00 0d - ................

TRACE:1:00000010 - 45 52 52 53 45 52 56 45 52 43 4f 52 45 00 00 00 - ERRSERVERCORE...

TRACE:1:00000020 - 00                                              - .

TRACE:1:Exception Caught: Recoverable:

TRACE:1:Stack trace: com.microfocus.cobol.connector.transport.BINPServerException: Recoverable:

TRACE:1: at com.microfocus.cobol.connector.transport.BINPCall.readStatusMessage(BINPCall.java:1605)

TRACE:1: at com.microfocus.cobol.connector.transport.BINPCall.readStatusMessage(BINPCall.java:1427)

TRACE:1: at com.microfocus.cobol.connector.transport.BINPCall.execute(BINPCall.java:286)

TRACE:1: at com.microfocus.cobol.connector.transport.TraceTransport.execute(TraceTransport.java:219)

TRACE:1: at com.microfocus.cobol.connector.transport.TraceToStdOutTransport.execute(TraceToStdOutTransport.java:11)

TRACE:1: at com.microfocus.cobol.connector.PureCobolBean.cobcall(PureCobolBean.java:317)

TRACE:1: at com.microfocus.cobol.connector.EnterpriseServerBean.cobcall(EnterpriseServerBean.java:176)

TRACE:1: at com.microfocus.cobol.connector.EnterpriseServerBeanHelper.exec(EnterpriseServerBeanHelper.java:295)

TRACE:1: at com.microfocus.cobol.connector.EnterpriseServerBeanHelper.execute(EnterpriseServerBeanHelper.java:261)

TRACE:1: at net.mypackage.HelloWorld.DirectConnection.sayHello(DirectConnection.java:68)

TRACE:1: at net.mypackage.HelloWorld.JavaJ2SECaller.CallService(JavaJ2SECaller.java:21)

TRACE:1: at net.mypackage.HelloWorld.JavaJ2SECaller.main(JavaJ2SECaller.java:13)

TRACE:1:end stack trace

TRACE:1:true=getConnectionProperty(BeanInitialProperty,null)

TRACE:1:getConnectionProperty(BeanInitialProperty)=true

TRACE:1:disconnect()

TRACE:1:removeConnectionProperty(CobolConnection)

*--> String returned by ES Service: true

com.microfocus.cobol.CobolException: Recoverable:

at com.microfocus.cobol.connector.EnterpriseServerBeanHelper.exec(EnterpriseServerBeanHelper.java:308)

at com.microfocus.cobol.connector.EnterpriseServerBeanHelper.execute(EnterpriseServerBeanHelper.java:261)

at net.mypackage.HelloWorld.DirectConnection.sayHello(DirectConnection.java:68)

at net.mypackage.HelloWorld.JavaJ2SECaller.CallService(JavaJ2SECaller.java:21)

at net.mypackage.HelloWorld.JavaJ2SECaller.main(JavaJ2SECaller.java:13)

<br />

Thanks

Anil