cancel
Showing results for 
Search instead for 
Did you mean: 

JCO error when creating client

Former Member
0 Kudos

Hi. I am trying to execute some sample code to connect to SAP. I have encountered a few different errors along the way, and have read the error descriptions in the JCO documentation.

I have placed sapjcorfc.dll in my system32 directory. That solved one problem, but now I am receiving this error:

java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'

default_cpc_mode

at com.sap.mw.jco.JCO.<clinit>(Unknown Source)

at jcotest.JcoTest.main(JcoTest.java:44)

Exception in thread "main"

Here is the code:

JCO.Client sapconn = null;

JCO.Repository saprep = null;

JCO.Function func = null;

JCO.Table table = null;

try

{

System.out.println("Creating client...");

// Error on next line:

sapconn = JCO.createClient(client,

user,

pwd,

lang,

sys,

sysno);

System.out.println("Got client. Connecting...");

...

I also replaced librfc32.dll with the new version from the JCO distribution, and I still received the same error.

Thanks in advance for your feedback.

Brendan

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

This thread is ancient but it crops up in all google searches so I thought I would post a solution anyway.

I had exactly the same problem and tried all of the above without success.  The solution in my case was to make sure the JVM and sapjco3.dll were the for the same platform.  I had the 64 bit JCO3 running with 32 bit JVM.  I changed and installed the 32 bit JCO3 version.

Go to Start>Control Panel>Java to check JVM version.

If that doesn't work try these:

1. JCO 3 problems with Library - UnsatisfiedLinkError [SOLVED] - Toolbox for IT Groups

3. Error: sapJco3 load the Java library

Former Member
0 Kudos

MSVCR71.DLL does not exist on W2K - you need to get from microsoft. Or you can downgrade JCo version - use 2.1.3

Former Member
0 Kudos

Sorry, but I got thjis libraries from the Windows 2000, copy to the Windows XP, also I got the librfc32.dll version 6.40, and its working fine now.

Former Member
0 Kudos

I solved the problem by adding two DLL in \system32.

You can download a freeware application (DEPENDENCY WALKER) that checks dependencies trough DLL libraries. You insert in the mask the sapjcorfc.dll; the program test it and show the missing libraries linked to that.

In particular, my system didn't find the MSVCR71.DLL and MSVCP71.DLL located in WINDOWS\system32.

Hope it helps.

Sorry for my english!

Former Member
0 Kudos

Hello,

I am still having problems connecting to sap. Could any one tell me where to down load these dlls? MSVCR71.DLL and MSVCP71.DLL ?

More over I'm using WIN XP as my OS and the librfc32.dll is onle 4.82 MB

and the initial librfc32.dll(the one that was initially there) is 7.42MB(does this means that this is a newer version?)

When ever I replace the initial dll(librfc32.dll in XP which is 7.42MB) with the jco dll (librfc32.dll with 4.82MB)which comes with jco, the SAP GUI installed in my PC doesn't start any more. It does start only if I replace the jco dll file with the XP dll (librfc32.dll with 7.42 MB)

Is there any where with a jco installation for WIN XP?

Could any body please help me out? I'm a newbie ready to learn sir!

Former Member
0 Kudos

Hi,

I got the same problem, let show what hapepnds:

1. My test progrma using JCO worts in windows 2000

2. In windows XP doesn´t work, requires the MSVCR71.DLL.

3. This DLL already existe in Windows 2000.

There is something estrange that happends:

When I replace the librfc32.dll, in windows XP, may SAP client stop working, and I get the MSVCR71.DLL error for fist time.

Any ideas?

Tjhis kind of troublles doesn't surprise me, anything, is Microsfot Windows

Former Member
0 Kudos

Pleople. my conclusio at the end of the day: The sampke program works in windows 200, but it doesnt work in Windows Xp.

What I have to do now in order to work in Windows XP is: To get the most recent version of the RFC Library.

The version taht comes with JCo is 6.20, but un winXP you need 6.40 or over.

The most recent version you get from services.sap.com/patches.

I hope this help you.

Former Member
0 Kudos

look at this thread if it can help you out.

Former Member
0 Kudos

Thanks for the advice, Vijaya. I got a little bit further...

I am using Eclipse as my IDE. When I set my bootstrap classes to look at the jco directory (Run... menu), I did not receive the middleware error message, but now I am getting this parsing error on the JCO.createClient method:

java.lang.ExceptionInInitializerError: java.lang.NumberFormatException: N

at java.lang.Integer.parseInt(Integer.java:423)

at java.lang.Integer.parseInt(Integer.java:472)

at com.sap.mw.jco.JCO.setProperty(JCO.java:608)

at com.sap.mw.jco.JCO.<clinit>(JCO.java:739)

at jcotest.JcoTest.main(JcoTest.java:44)

Exception in thread "main"

I tried to trim the string arguments, hard code the arguments right into the method call, and I keep getting the same message.

Brendan

Former Member
0 Kudos

Hi,

In one of the PDF files that come with sapjco it explains that you have to copy a dll file into the system32 folder of your Windows installation driver...

I don't have the PDF now so I can't give much details, but this might be the issue!

Former Member
0 Kudos

Thank you for replying.

I saw the documentation that you are referring to. I added the sapjcorfc.dll to the system directory. I had copied the old version of librfc32.dll that exists in the system32 directory to a holding folder and copied the newer version to the system32 directory. This did not help matters.

I also noticed a librfcu.dll file on my machine. Could this be creating a conflict?

Thank you.

Former Member
0 Kudos

Hi Brendan,

From your mail, I understand that you have gone through the documentation. The exception is thrown because the JCO classes are not able to find and load the middleware DLL sapjcorfc.dll . As the document( Runtime Loading Mechanism) specifies, it tries to load this DLL either from the directory where sapjco.jar is there or from your java.library.path or your OS path variable. Put sapjcorfc.dll in path. If it doesn't solve the problem, check for the versions of SAPJCO.jar and sapjcorfc.dll. They are tightly coupled and must be of same version. Hope this solves the problem.

Former Member
0 Kudos

Well Brendan, I too had similar problems when I first Setup the SapJco. I would recommend that you do the foloowing two steps.

1) Make Sure your Classpath is set to the place where the sapjco.jar file is copied onto your Computer. This can be done using the environment variables set up.

2)The next thing would be to make sure that you have imported the required jar files onto your application. If you are using any standard IDE like eclipse or netweaver or websphere, then just place the sapjco.jar file into your lib folder.

if you still get the error messages reply back with the following details....What version of Jco did you download...and What version of J2ee engine you are running and also the WebApplication server that you are using.

Ravi

Former Member
0 Kudos

Thank you both for replying.

Ravi - I downloaded SAP Java Connector 2.1.3 (According to the Readme.txt file). Just to give you every detail possible, I extracted the sapjco.jar from the downloaded zip file and that is the jar that I am including in my classpath.

I am using Eclipse as my IDE, and I am simply trying to have the program connect from the client machine. I tried what you had said. I included the path to the jar file in my classpath variable, and I also imported the jar into my project.

Forgive my ignorance, but this is the first time that I am using the connector. The QAS server that I am trying to connect to is running R3. Is there anything additional that I need running on the server to connect?

I am still getting the following output when I run the code:

Creating client...

java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'

default_cpc_mode

at com.sap.mw.jco.JCO.<clinit>(Unknown Source)

at jcotest.JcoTest.main(JcoTest.java:44)

Exception in thread "main"

Thanks.

BF

Former Member
0 Kudos

Hi Brendan,

Did you set a reference from your application (in the application-j2ee-engine.xml) to the SAPJCO library (library name: com.sap.mw.jco) on the J2EE Engine? You need that reference so that the classloader be able to load necessary JCo classes.

Hope that helps.