cancel
Showing results for 
Search instead for 
Did you mean: 

SAP JCo

larry_chaput
Participant
0 Kudos

Hi all,

I am continually getting this java.lang.NoClassDefFoundError: com/sap/mw/jco/IFunctionTemplate

error when trying to run the Java Connector.

I have the latest JCo.jar which I put in a common location and referenced it... in eclipse I went to the project properties, then to the java build path, then the libraries tab and added the external jar.

The other two files sapjcorfc.dll and librfc32.dll are in C:\windows\system32.

running this scenario I continually get the aforementioned error.

As soon as I copy the jar into the WEB-INF/lib directory everything works fine.

n e ideas?

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Larry,

Since you mentioned the WEB-INF/lib directory, I guess you're calling JCo from a servlet/JSP. Then you have to declare a runtime reference to the com.sap.mw.jco library in your application-j2ee-engine.xml descriptor, just like this:

<reference reference-type="weak">
  <reference-target target-type="library" provider-name="sap.com">
    com.sap.mw.jco
  </reference-target>
</reference>

What you have done with the Libraries tab in the Java Build Path is only adding a build-time reference.

HTH,

Vladimir

larry_chaput
Participant
0 Kudos

Thanks for all the replies!

I'm sorry, I should have specified earlier but I am developing a web application, servlet/jsp, and am using Tomcat 4.1 as my server.

Therefore I'm not sure that I'll be able to find a application-j2ee-engine.xml file.

The two files sapjcorfc.dll & librfc32.dll are in the same directory as the JCo jar.

Any other thoughts?

Message was edited by: Larry Chaput

Vlado
Advisor
Advisor
0 Kudos

Hi Larry,

Then you have already found how to do that - just put the JCo jar in the WEB-INF/lib directory of your web app. Or you could add it to the classpath of your Tomcat server - thus you can use it from other apps too without falling into classloader conflicts. The idea is always the same - you must have the jar on the application classpath at runtime.

HTH,

Vladimir

PS: Please consider rewarding points for helpful answers.

larry_chaput
Participant
0 Kudos

Perhaps I'll elaborate a little furthur. Initially, I had my JCo jar as well as the two required dll's sitting in the WEB-INF/lib folder ... I had also dropped those dll's in the c:\windows\system32 directory. The web app would work but as soon as I would reload the project and try to run it again I would receive the following error.

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

Native Library C:\WINDOWS\system32\sapjcorfc.dll already loaded in another classloader

After restarting the webserver I am able to run it again however this is hardly a reasonable way to work. I did some research and soon found the cause of the problem which is listed in SAP note 542175 ... the dll cannot be loaded into multiple classloaders (which my error message kinda tells me but the note is a little clearer). By reloading my webapp it was loading it into another classloader. At this point it would fail. The note goes on to list a solution which is to pull the JCo jar out of the WEB-INF/lib folder and just reference it from a central location. It is at this point where I did exactly that (removed the files from the WEB-INF/lib folder) and made a reference to it under the libraries tab. Its at this point that I received the first error I had listed in these series of posts.

Phew, that was a mouthful

Vlado
Advisor
Advisor
0 Kudos

Hi Larry,

As I wrote earlier, what you do under the Libraries tab in the Java Build Path is only for build-time references. You must also declare a runtime reference so that the JCo classes be available to your application at runtime. In SAP Web AS 6.40 this is done in the application-j2ee-engine.xml. Not sure about Tomcat but I think you can change the server classpath to include the JCo jar.

Best regards,

Vladimir

Former Member
0 Kudos

Larry,

DLL-classloader restrictions imply that you should put mentioned jars into server's classpath. On Tomcat, you can do this placing them into $/commom/lib

--

Sam Mesh

larry_chaput
Participant
0 Kudos

Thank you so much ... nice clean, concise answer ... much appreciated

Former Member
0 Kudos

"... nice clean, concise" ... and working?

Message was edited by: Sam Mesh

larry_chaput
Participant
0 Kudos

you bet .... hence the points I gave you for solving my problem

Former Member
0 Kudos

Hi all,

I am trying to install the SAP JCo with WebSphere Application Server 5.1.1.1 to make it available in WPS 5.1.

I followed the installation procedure for the Linux 32 JCo 2.1.6 on a SuSE 9.3 Professional:

1. Installed the sapjco.jar along with the other two files librfccm.so and libsapjcorfc.so in $/lib/ 2. Set the LD_LIBRARY_PATH to $/lib/

3. Set the CLASSPATH to $/lib/sapjco.jar.

We have it working on our Windows WPS dev platform -- it is a basic echo-the-jco-version-service, however it doesn't work on our linux box.

Can anyone help me?

TIA

Michel

Former Member
0 Kudos

Check your point 2 : LD_LIBRARY_PATH...

This is vastly different and depends on the unix flavor...

AIX, Solaris, Linux all use the same concept but the environment variable has a slightly different spelling...on each. The JCO installation section of the manual should give some indication on which name to use on which platform.

Enjoy

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Larry,

Where you are using this JCO?

means in webdynpro app. or in EJB or in JAVA class?

If you are using in EJB then make a sharing reference in the applicatio-j2ee-engine.xml.

Add following reference there.

com.sap.mw.jco

Take the reference type as Weak here.

and do not export sapjco.jar file with this ejb jar.

Add sapjco.jar file reference in library tab in property only for refering at design time.

And at runtime it will take from the server side only so for that you have to add share reference in application project for this ejb.

Let me know the status,

Regards,

Bhavik

Former Member
0 Kudos

Hi Larry,

Place the "sapjcorfc.dll" & "librfc32.dll" files in the same folder where "JCo.jar" file is. Now try executing and test the application.

Regards,

Santhosh.C

Former Member
0 Kudos

Where are you running this code? Is it as SAP's J2ee engine?

if it's sap's j2ee engine then add the sapjco.jar to the class path of j2ee server node.