通过Java连接SAP时发生异常 [英] Exception while connecting SAP through Java

查看:211
本文介绍了通过Java连接SAP时发生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您告诉我解决以下问题的解决方案---

Can you please tell me the solution to fix this below issue ---

即使sapjco3.jar在我的库路径中,我仍试图通过Java类连接SAP相关文件时遇到此异常.我在Windows XP&Windows Server 98.

This Exception I am getting while trying to connect SAP related files through Java class even though sapjco3.jar is in my library path.I tried this in Windows XP & Windows Server 98.

java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.sap.conn.jco.rt.DefaultJCoRuntime.loadLibrary(DefaultJCoRuntime.java:441)
at com.sap.conn.jco.rt.DefaultJCoRuntime.registerNativeMethods(DefaultJCoRuntime.java:307)
at com.sap.conn.jco.rt.JCoRuntime.registerNatives(JCoRuntime.java:987)
at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:948)
at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:43)
at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:259)
at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:200)
at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:73)
at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
at com.sap.conn.jco.rt.RuntimeEnvironment.<init>(RuntimeEnvironment.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sap.conn.jco.ext.Environment.getInstance(Environment.java:121)
at com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(Environment.java:216)
at de.vogella.sap.rfc.core.connection.Connection.<init>(Connection.java:37)
at struct.actions.GestReservaSap.<clinit>(GestReservaSap.java:63)
at eu.sony.com.moduloreservas.ReservasMainClass.main(ReservasMainClass.java:259)

推荐答案

SAP Java连接器内部使用本机库连接到SAP.该本机库不是sapjco3.jar,而是sapjco3.dll(在Windows系统上).IE.dll文件必须位于Java库路径中的文件夹中.

The SAP Java Connector internally uses a native library to connect to SAP. This native library is not the sapjco3.jar but the sapjco3.dll (on Windows systems). I.e. the dll file must be in a folder which is in your Java library path.

后者是Java系统属性,您可以通过调用

The latter is a Java system property, you can access it in your application by calling

System.getProperty("java.library.path")

然后,您可以将sapjco3.dll放入库路径中已经存在的一个文件夹中(在Windows上,例如C:\ WINNT \ system32之类),也可以将库路径设置为特定文件夹通过显式设置库路径:

Then you can put the sapjco3.dll either into one of the folders which are already in your library path (on Windows e.g. something like C:\WINNT\system32) or the other way around set the library path to a specific folder by explicitly setting the library path:

    通过设置应用程序代码中的
  • System.setProperty("java.library.path","C:\ path \ to \ folder \ with \ dll \")在访问SAP JCo之前
  • 或使用命令行参数启动Java时 -Djava.library.path = C:\ path \ to \ folder \ with \ dll \
  • in the application code by setting System.setProperty("java.library.path", "C:\path\to\folder\with\dll\") before accessing the SAP JCo
  • or when starting Java with the command line argument -Djava.library.path=C:\path\to\folder\with\dll\

由于将dll放入系统专用文件夹(例如winnt \ system32)可能不仅对您的应用程序有影响,而且对其他人也有影响,因此建议将包含sapjco3.dll的文件夹添加到应用程序的库路径.更加灵活的方法是通过如上所示的命令行指定它,这样您就不必对其进行硬编码了.

Since putting the dll into a system specific folder like winnt\system32 may have effects not only to your application but to others as well, it is recommended to add the folder containing the sapjco3.dll to your application's library path. The more flexible way is to specify it via the command line as shown above so you don't have it hard coded.

这篇关于通过Java连接SAP时发生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆