wangJiaLun-go

王加伦的技术分享

0%

no sapjco3 in java.library.path

问题记录: no sapjco3 in java.library.path

对接厂家的SAP系统, 部署至linux环境时报下面的错误日志, 查了缺libsapjco3.so包

对应包下载地址 链接:https://pan.baidu.com/s/1YO0ZJq4J_SL9dI8VyuDsBg 提取码:8888

查了很多帖子是放在tomcat里, 现在springboot直接jar跑不方便加进去, 下面是配置到环境变量中

  • 错误日志

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1088)
    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:969)
    at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:955)
    at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:43)
    at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:261)
    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 java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.sap.conn.jco.JCo.createJCo(JCo.java:52)
    at com.sap.conn.jco.JCo.<clinit>(JCo.java:26)
    at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:61)
    at com.changhong.vmi.admin.xfire.jco.SrmSapJCo.getGoodsPlan(SrmSapJCo.java:79)
  • 解决方案

    sapjco3.jarlibsapjco3.so上传到服务器上, 配置 /etc/profile

    1
    2
    3
    4
    5
    6
    7
    #java environment
    export JAVA_HOME=/usr/local/jdk/jdk1.8.0_181
    export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/lib/sapjco3.jar
    export PATH=$PATH:${JAVA_HOME}/bin

    # 我把libsapjco3.so上传到这个路径下了
    export LD_LIBRARY_PATH=/usr/local/jdk/jdk1.8.0_181/jre/lib/amd64/server