Errors when running the JCOtest utility for the SAP UM driver

  • 7011246
  • 25-Oct-2012
  • 25-Oct-2012

Environment

NetIQ Identity Manager

Situation

Getting Java errors when trying to run the JCO test utility for the SAP drivers.

Resolution

Things to consider:
1) check the architecture of the JVM and SAP JCO client library ( libsapjco3.so )
2) the classpath should point to the directory where the class files are, not to the file itself. A jar file is actually a bundle of directories and classes, that is why that one is pointed by name. so it should be:
export CLASSPATH=/sources/idm361/SapJCO3/sapjco3.jar:/opt/novell/eDirectory/lib/dirxml/rules/sapum:/opt/novell/eDirectory/lib/dirxml/rules
3) We need (on Linux) to use LD_LIBRARY_PATH or to make sure the libsapjco3.so file is installed as a system library. For the first option the line would be:
export LD_LIBRARY_PATH=/sources/idm361/SapJCO3
 
 
  So assuming both their JVM and JCO are the same architecture (32 or 64 bits), the process would be:
export LD_LIBRARY_PATH=/sources/idm361/SapJCO3
export CLASSPATH=/sources/idm361/SapJCO3/sapjco3.jar:/opt/novell/eDirectory/lib/dirxml/rules/sapum
/opt/novell/jre/bin/java -classpath $CLASSPATH UserJCO3Test
 
Here are some examples of the errors and how to fix them:
Error:
 
Exception in thread "main" java.lang.NoClassDefFoundError: UserJCO3Test/class
Caused by: java.lang.ClassNotFoundException: UserJCO3Test.class
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: UserJCO3Test.class.  Program will exit.
possible causes:
- classpath pointing to the class file, not the directory that contains the class
- added the .class in the java call, that will be read as "directory named UserJCO3Test, class file name class"
 
Error:
 
java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.loadLibrary(DefaultJCoRuntime.java:425)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.registerNativeMethods(DefaultJCoRuntime.java:293)
        at com.sap.conn.jco.rt.JCoRuntime.registerNatives(JCoRuntime.java:891)
        at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:948)
        at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:41)
        at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:253)
        at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:195)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:74)
        at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.sap.conn.jco.JCo.createJCo(JCo.java:51)
        at com.sap.conn.jco.JCo.<clinit>(JCo.java:25)
        at UserJCO3Test.main(UserJCO3Test.java:196)
 
Exception while initializing JCO client.
java.lang.ExceptionInInitializerError: Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: com.sap.conn.rfc.driver.CpicDriver.nativeCpicGetVersion([I)I
Verify proper installation of JCO Native support libraries packaged with JCO client.
 
- library libsapjco3.so is not found by Java. Make sure Java can find the library file. Easies way on Unix/Linux is to set LD_LIBRARY_PATH to the *directory* that contains said file.
 
Error:
 
java.lang.UnsatisfiedLinkError: /root/sapjco3-linuxx86_64-3.0.2/libsapjco3.so: /root/sapjco3-linuxx86_64-3.0.2/libsapjco3.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(Unknown Source)
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.loadLibrary(DefaultJCoRuntime.java:425)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.registerNativeMethods(DefaultJCoRuntime.java:293)
        at com.sap.conn.jco.rt.JCoRuntime.registerNatives(JCoRuntime.java:891)
        at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:948)
        at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:41)
        at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:253)
        at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:195)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:74)
        at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.sap.conn.jco.JCo.createJCo(JCo.java:51)
        at com.sap.conn.jco.JCo.<clinit>(JCo.java:25)
        at UserJCO3Test.main(UserJCO3Test.java:196)
 
Exception while initializing JCO client.
java.lang.ExceptionInInitializerError: Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: com.sap.conn.rfc.driver.CpicDriver.nativeCpicGetVersion([I)I
Verify proper installation of JCO Native support libraries packaged with JCO client.
 
possible causes:
- Java arquitecture is different from the JCO3 library arquitecture. Make sure both are either 32 bits or 64 bits.