今天将一个老项目部署到一台新liunx服务器之后报错信息如下: no sapjco3 in java.library.path。
## 报错信息
Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:229)
at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:98)
at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
at com.sap.conn.jco.rt.RuntimeEnvironment.<init>(RuntimeEnvironment.java:43)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at com.sap.conn.jco.ext.Environment.getInstance(Environment.java:155)
at com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(Environment.java:259)
at com.pda.jco.dataprovider.MyDestinationDataProvider.<clinit>(MyDestinationDataProvider.java:27)
at com.pda.service.impl.FunctionExecuteServiceImpl.setJCoDestination(FunctionExecuteServiceImpl.java:48)
at com.pda.service.impl.FunctionExecuteServiceImpl.login(FunctionExecuteServiceImpl.java:114)
at com.pda.service.impl.FunctionExecuteServiceImpl$$FastClassByCGLIB$$467dda3f.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:634)
at com.pda.service.impl.FunctionExecuteServiceImpl$$EnhancerByCGLIB$$d898e192.login(<generated>)
at com.pda.action.LogintomainAction.check(LogintomainAction.java:117)
## 排查思路
看着报错信息,应该与SAP交互有关,主要是sapjco3包的问题,咨询了SAP开发的小伙伴,告知win部署与liunx部署对应的jar包不同。(老的部署文档里面未说明,囧~~~)
## 解决思路
查看下正式环境liunx下的lib包,发现部署的是sapjco3.jar、libsapjco3.so
而自己是从本地部署的项目发现部署的是sapjco3.jar、sapjco3.dll
将上传到liunx的sapjco3.dll 删除,重新上传libsapjco3.so,重启tomcat解决。
SAP RFC接口对应Java jar包如下
liunx :libsapjco3.so
win:sapjco3.dll
相关资源包下载地址: sapJco3相关资料包-Java文档类资源-CSDN文库