Error getting the version of the native layer: jav

2019-08-08 18:07发布

问题:

In my java web application, trying to connect SAP Server. This error is generated. I have placed the sapjco3.dll and sapjco3.jar in WEB-INF/lib/ and also configured in the Java Build Path. I have also set the Path in servlet as

System.setProperty("java.library.path", "/WEB-INF/lib");

But also error existing.

回答1:

There are several issues in your approach

  1. It is not recommended to change java.library.path programmatically, since the property is cached at the JVM start. See Setting "java.library.path" programmatically for more details.

  2. You are overwriting java.library.path instead of adding your directory at the end. It's very likely your application server needs some native libraries of its own.

  3. /WEB-INF/lib is a relative path which your JVM is not going to find as the JVM root directory is different from your app root directory (not to mention if you are deploying a WAR file)

In general, you should configure your SAP JCo as a server library, not an application library. The exact procedure depends of your application server.



回答2:

If you are on Windows like me you can put the sapjco3.dll anywhere you want in the file system (except for the Windows system32 and sysWOW64 directories, as stated in the sapjco3 documentation) and then add the path to it to your Path system variable:

On Linux you add the path to the libsapjco3.so file to the environment variable LD_LIBRARY_PATH

If you are on JBoss and need to get sapjco3.jar into you project see my answer over here: https://stackoverflow.com/a/21901220/1592796