Highlighted
Absent Member.
Absent Member.
5606 views

Execute Java from Visual COBOL on AIX

Jump to solution

[Migrated content. Thread originally posted on 18 April 2012]

Hello,

I am trying to invoke a Java class from Visual COBOL, following these lines:

Declaring Java Classes

But I am not able to do it. This is the error that appears:
Load error : file '$java$vertex.Vertex'                                         
error code: 198, pc=0, call=1, seg=0                                           
198     Load failure

Java by itself is running well.

The Java module is defined inside the package 'vertex' and my class is named 'Vertex'. I wrote this class using NetBeans, under Windows, and copied the JAR file to the AIX server. The COBOL program has been written without using Eclipse, too.
The lines below belong to this program:
      $set ooctrl"+p-f"
       program-id. prvertex as "prvertex".
       
       environment division.
       configuration section.

       repository.
         class Vertex as "$java$vertex.Vertex.jar".

       data division.
     
       working-storage section.       
       copy "javatypes.cpy".
       
       01 aJavaObj             object reference.
       
       01 theTotal        pic 9(9).
       01 CDims           pic x(4) comp-5.
       01 Dims.
          03 Dims-entry    pic x(4) comp-5 occurs 256.
       01 Bounds.
          03 Bounds-entry  pic x(4) comp-5 occurs 256.
       01 ind0            pic x(4) comp-5.
       01 ind1            pic x(4) comp-5.
       01 arrayElement    pic x(4) comp-5.
       01 wsTable         object reference.
       01 wsResult        pic x(4) comp-5.
             
       procedure division.
           invoke Vertex "new" returning aJavaObj.

         goback.

       
       end program prvertex.

What am I doing wrong?

Thank you
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
It looks like the JVM to have trouble finding libnet.so, I will do some more investigating and get back to you.

View solution in original post

0 Likes
9 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Execute Java from Visual COBOL on AIX

Jump to solution
I believe that you need to just reference the class name in the class description and add the jar file to your CLASSPATH.

change:
class Vertex as "$java$vertex.Vertex.jar".
to:
class Vertex as "$java$vertex.Vertex".

and put Vertex.jar on your CLASSPATH.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
Hello Chris,

That is was I thought, too. But I have also tried this (in fact, that was my first attempt). I also removed the package from the repository reference and checked out other possible combinations, with the same result.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
The problem is that I wasn't using cobjrun. But if I use it, I obtain:
>VC_RCJAVA PRX                                           
                                                                               
/swmango/visualcobol/devhub/bin/cobjrun64: Could not load libjvm.so   

It seems that cannot find 'libjvm.so', but

:>find . -name "libjvm.so" -exec ls -la {} \;             
-r-xr-xr-x    1 bin      bin          125198 Jul 05 2011  ./jre/bin/classic/libjvm.so                                                                           
-r-xr-xr-x    1 bin      bin          125198 Jul 05 2011  ./jre/bin/j9vm/libjvm.so                                                                             
-r-xr-xr-x    1 bin      bin          125198 Jul 05 2011  ./jre/lib/ppc/classic/libjvm.so                                                                       
-r-xr-xr-x    1 bin      bin          247926 Jul 05 2011  ./jre/lib/ppc/j9vm/libjvm.so                   

>echo $PATH                                               
/usr/java6/jre/bin:/usr/java6/jre/bin/classic:/usr/java6/bin:/usr/java6/jre/sh:/usr/java6/jre/bin:/usr/java6/sh:/swmango/visualcobol/devhub/bin:/usr/java6/bin:/usr/bin:/usr/sbin:/MNG/DESA/FUENTES/EQBASE/BIN:/swmango/scripts/EXPL:/swmango/scripts/DESA:/swmango/rmcobol/EXPL:/swmango/rmcobol/DESA:.:/MNG/DESA/FUENTES/EQBASE/VC:/usr/vacpp/bin

>echo $LIBPATH                                           
/usr/java6/jre/bin:/usr/java6/jre/bin/classic:/usr/java6/lib/aix/native_threads:
/usr/java6/bin/aix/native_threads:/swmango/visualcobol/devhub/lib

>echo $CLASSPATH                                         
/usr/java6/lib:/swmango/visualcobol/devhub/lib/mfcobol.jar:/swmango/visualcobol/devhub/lib/mfcobolrts.jar:/MNG/DESA/FUENTES/EQBASE/VC/java/vertex/Vertex.jar:/MNG/DESA/FUENTES/EQBASE/VC/java/x.jar
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
Hi voyager, are you using a 32bit JVM? If you are then the problem is that cobjrun is triggering cobjrun64 which wont work with a 32bit JVM. You either need to install a 64bit JVM (if running in 64bit is your intention) or set the COBMODE environment variable to 32.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
I see it. Thank you, Chris.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
Hello again,

My program works perfectly if I launch it directly:
[03500309@aixlab0102]:>java -DproxyHost=proxy.intranet.mango.es -DproxyPort=8080 -jar Vertex.jar 
Executing Comm...                                                               
plz wait....buyer address                                                       
createBuyerType                                                                 
order lines                                                                     
line 1                                                                         
order 2                                                                         
linea 2                                                                         
Filling the purchase                                                           
inputEnvelope                                                                   
Login                                                                           
Envelope                                                                       
attempt to calculateTax60...                                                   
Total tax order is: 17.71                                                       
                                                                               
L Item         Price Tax                                                       
= ============ ===== =====                                                     
1 636200279902 100.0 7.0                                                       
2 614403713602 153.0 10.71   

But does not work when I invoke it from Visual COBOL:
[03500309@aixlab0102]:>VC_RCJAVA PRVERTEX                                       
                                                                               
Executing Comm...                                                               
plz wait...                                                                     
                                                                               
Exception 65537 not trapped by the class javaexceptionmanager.                 
Description: "Java exception"                                                   
net (A file or directory in the path name does not exist.)                     
Hit T to terminate program. Hit any other key to continue. 

It seems that cannot find the net library... ¿¿??
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
What exactly is "VC_RCJAVA" doing? Is it setting the jar location and the proxy properties?

What happens if you use the command line:

cobjrun -DproxyHost=proxy.intranet.mango.es -DproxyPort=8080 -jar Vertex.jar

When you do it from Visual COBOL, have you got "/MNG/DESA/FUENTES/EQBASE/VC/java/vertex/Vertex.jar" on CLASSPATH? (And any other required environment set up?)
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
Chris Whitty originally wrote:
What exactly is "VC_RCJAVA" doing? Is it setting the jar location and the proxy properties?

What happens if you use the command line:

cobjrun -DproxyHost=proxy.intranet.mango.es -DproxyPort=8080 -jar Vertex.jar

[03500309@aixlab0102]:>cobjrun -DproxyHost=proxy.intranet.mango.es -DproxyPor> 
Executing Comm...                                                               
plz wait.../swmango/visualcobol/devhub/bin/cobjrun32: vertex.Vertex.main ended d
ue to an exception                                                             
Exception in thread "main" java.lang.UnsatisfiedLinkError: net (A file or direct
ory in the path name does not exist.)                                           
        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1018)     
        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:982
)                                                                               
        at java.lang.System.loadLibrary(System.java:469)                       
        at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:69)
        at java.security.AccessController.doPrivileged(AccessController.java:202
)                                                                               
        at java.net.PlainSocketImpl.(PlainSocketImpl.java:113)         
        at java.lang.J9VMInternals.initializeImpl(Native Method)               
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)           
        at java.net.Socket.(Socket.java:136)                             
        at sun.net.NetworkClient.doConnect(NetworkClient.java:161)             
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:407)         
        at sun.net.www.http.HttpClient$4.run(HttpClient.java:470)               
        at java.security.AccessController.doPrivileged(AccessController.java:251
)                                                                               
        at sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:452)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:533)         
        at com.ibm.net.ssl.www2.protocol.https.c.(c.java:161)             
        at com.ibm.net.ssl.www2.protocol.https.c.a(c.java:73)                   
        at com.ibm.net.ssl.www2.protocol.https.d.getNewHttpClient(d.java:2)     
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:921)                                                                 
        at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:46)             
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1182)                                                             
        at com.ibm.net.ssl.www2.protocol.https.b.getInputStream(b.java:84)     
        at java.net.URL.openStream(URL.java:1022)                               
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(Ru
ntimeWSDLParser.java:805)                                                       
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(Run
timeWSDLParser.java:263)                                                       
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWS
DLParser.java:130)                                                             
        at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceD
elegate.java:267)                                                               
        at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDele
gate.java:230)                                                                 
        at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDele
gate.java:178)                                                                 
        at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Provid
erImpl.java:93)                                                                 
        at javax.xml.ws.Service.(Service.java:67)                         
        at com.vertexinc.oseries.services.calculatetax60.CalculateTaxWSService60
.(CalculateTaxWSService60.java:47)                                       
        at vertex.Vertex.Comm(Vertex.java:57)                                   
        at vertex.Vertex.executeVertex(Vertex.java:32)                         
        at vertex.Vertex.main(Vertex.java:25)

Chris Whitty originally wrote:

When you do it from Visual COBOL, have you got "/MNG/DESA/FUENTES/EQBASE/VC/java/vertex/Vertex.jar" on CLASSPATH? (And any other required environment set up?)

Yes:

last lines of VC_RCJAVA:

export COBPATH=/MNG/DESA/FUENTES/EQBASE/VC/OBJ:.
export PATH=/swmango/scripts/EXPL:$PATH
export COBMODE=32
/swmango/visualcobol/devhub/bin/cobjrun -DproxyHost=proxy.intranet.mango.es -DproxyPort=8080 "$1" "$2" "$3" "$4" "$5"

(I have removed all non-related vars)
[03500309@aixlab0102]:>set                                                     
A_CONFIG=/MNG/DESA/FUENTES/EQBASE/VC/CFG/acurmfm.cfg                           
CLASSPATH=/usr/java6/lib:/swmango/visualcobol/devhub/lib/mfcobol.jar:/swmango/visualcobol/devhub/lib/mfcobolrts.jar:/MNG/DESA/FUENTES/EQBASE/VC/java/vertex/Vertex.jar                                                                         
COBCONFIG=/MNG/DESA/FUENTES/EQBASE/VC/CFG/cobconfig.cfg                         
COBCPY=/swmango/visualcobol/devhub/cpylib:/MNG/DESA/FUENTES/EQBASE/VC/CPY:/MNG/DESA/CPY                                                                         
COBDIR=/swmango/visualcobol/devhub                                             
COBMODE=32                                                                     
CONVERTSTATUS=rmstat                                                           
HOME=/MNG/DESA/FUENTES/EQBASE                                                   
IP=d-4437e64270d0.intranet.mango.es                                             
JAVAHOME=/usr/java6                                                             
JAVA_HOME=/usr/java6                                                           
KM_CRYPTO_LIB_PATH=/usr/lib/libkmcryptolib.so                                   
KM_SUPPORT_LIB_PATH=/usr/lib/libkmsvcshlib.so                                   
LANG=en_US                                                                     
LD_LIBRARY_PATH=/usr/java6/jre/bin:/usr/java6/jre/bin/classic:/usr/java6/lib/aix/native_threads:/usr/java6/bin/aix/native_threads:/swmango/visualcobol/devhub/lib                                                                               
LIBPATH=/usr/java6/jre/bin:/usr/java6/jre/bin/classic:/usr/java6/lib/aix/native_threads:/usr/java6/bin/aix/native_threads:/swmango/visualcobol/devhub/lib       
LINENO=1                                                                       
PATH=/usr/java6/jre/bin:/usr/java6/jre/bin/classic:/usr/java6/bin:/usr/java6/jre/sh:/usr/java6/jre/bin:/usr/java6/sh:/swmango/visualcobol/devhub/bin:/usr/java6/bin:/usr/bin:/usr/sbin:/MNG/DESA/FUENTES/EQBASE/BIN:/swmango/scripts/EXPL:/swmango/scripts/DESA:/swmango/rmcobol/EXPL:/swmango/rmcobol/DESA:.:/MNG/DESA/FUENTES/EQBASE/VC:/usr/vacpp/bin                                                       
PPID=4915360                                                                   
RMPATH=/MNG/DESA/FUENTES/EQBASE/VC/FUENTES:/swmango/visualcobol/devhub/bin:/usr/java6/bin:/usr/bin:/usr/sbin:/MNG/DESA/FUENTES/EQBASE/BIN:/swmango/scripts/EXPL:
/swmango/scripts/DESA:/swmango/rmcobol/EXPL:/swmango/rmcobol/DESA:.             
RUNPATH=/MNG/DESA/OBJ:/swmango/rmcobol/OBJ:/usr/rmcobol                         
R_SHLIB_LD_LIBRARY_PATH=/usr/lib                                               
SCRIPT=-ksh                                                                     
SHELL=/usr/bin/ksh                                                             
_=PRVERTEX                                                                     
exito=1
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Execute Java from Visual COBOL on AIX

Jump to solution
It looks like the JVM to have trouble finding libnet.so, I will do some more investigating and get back to you.

View solution in original post

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.