cancel
Showing results for 
Search instead for 
Did you mean: 

JCO not working on struts app but does work as java application

Former Member
0 Kudos

Hello, i have this java application that uses JCO to connecto to  SAP backend system and it's working fine.

Next i wanted to try those classes inside a web application. I'm using Struts 1.3 and Glassfish 4.1 and inside the web app it's not working, i get the following message:

     java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path

Does someone know what could be wrong? The sapjco3.jar file is in the projects libraries. I don't know what is missing, since it's working in my java app that's not web (just some classes).

I added the complete path on the VM options and escaped that error, but now i'm getting this one:

java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.rt.JCoRuntimeFactory

Accepted Solutions (0)

Answers (1)

Answers (1)

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Fernando,

the latter exception I can't explain without seeing more context, the first one is caused by the fact that JCo does not find its native library. Instead of adding the path to the VM options, please try to put the native library next to the sapjco3.jar that's the first place JCo is looking for it. In case the second issue remains then, a deeper look in the context would be required.

Best regards,

Markus

Former Member
0 Kudos

Hi Markus,

In fact de sapjco3.dll and sapjco3.jar are in the same directory.

I can get it to work on a simple java project, i think that the problem comes in terms of where to place those libraries (or something like that) in the glassfish deployment.

I'm using Netbeans+Glassfish by the way.

Hope this helps.

Thanks Markus.

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Fernando,

interestingly enough that JCo does not find the library, even though it is at the place, where it looks for it. I've never tried JCo on Netbeans & Glassfish, therefore would also have to investigate.

Best regards,

Markus

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Fernando,

I recommend not to deploy the JCo files together with your application.

Even if you get it to work, you might get into trouble if multiple applications do the same and the native library would be loaded multiple times then. JCo can only be loaded once in a process.

If possible, either create some separate project which can be referenced by all other applications or add the JCo into the web application server startup classpath.

Best regards,

Stefan