Skip to Content
avatar image
Former Member

SAP Java connector JCo NoClassDefFoundError

Hello gurus,

I have a problem with SAP and JCo 3.
My task is to create a simple JCo application which is going to be called from SAP.
I'm using the approach with creation of SM59 connection to access JCo.
I'm using JCo 3.0.14

I'm not a java developer and I do not have experience with setting class paths and so on. I have read forums in order to produce this application.

As a first step I have created very simple java application for test (its source is at the bottom). It uses one of the JCo classes. This app. throws an error when it is executed on the SAP server but it is executed fine on my windows PC.
The error is :
java.lang.ClassNotFoundException: com.sap.conn.jco.JCo
(the full error description is at the bottom)
So I would like first to resolve this issue with this test appl. before starting to work on the real application.

A few info about my workspace and the SAP server where JCo is started.

I am developing my application on a windows PC with Windows 10.
I am using:
Eclipse Java EE IDE for Web Developers.
Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200

SAP server is linux machine.
Java version is:
java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)

I have set up the two environment variables:
echo "$CLASSPATH"
usr/sap/PW1/sapjco3/sapjco3.jar:/sapjco/libsapjco3.so

echo "$LD_LIBRARY_PATH"
usr/sap/PW1/sapjco3/

On my PC:

I'm starting eclipse via bat file with the following command:

C:\NWCEIDE04P_2-80000648\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_101\bin\javaw.exe"

i produce a .class file. I have tried with manifests also but again errors occur.occur.


When I run the application on my PC it is running fine. No errors occur.
I'm running a .class file.
In order to run it on my Windows PC I'm using the following commands:

set path="C:\Program Files\Java\jdk1.8.0_101\bin\ C:\workspace\D2\bin>java -cp . daimler.Server02


I suppose that the 1st line -> set path must be somehow performed on the server also, but I do not know how.

On the SAP server.
I am copying my bin directory from my PC on the SAP server and i use the following command to start the app:

java -cp . daimler.Server02

Now the following error occurs:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo
        at daimler.Server02.step4StaticRepository(Server02.java:18)
        at daimler.Server02.main(Server02.java:40)
Caused by: java.lang.ClassNotFoundException: com.sap.conn.jco.JCo
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 2 more

I suppose that I have to point somehow the path to java jdk as I do it on my PC.

This is the source code of my JCo application:

package daimler;
import com.sap.conn.jco.JCo;
import com.sap.conn.jco.JCoCustomRepository;
public class Server02 {
 static String SERVER_NAME1 = "SERVER";
 
  static void step4StaticRepository()
     {
        JCoCustomRepository cR = JCo.createCustomRepository("MyCustomRepository");
      }
  
  public static void main(String[] a)
     {
      System.out.println("Start\r\n");
         step4StaticRepository();
     }
}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers