因SAP升级引起SAP通过jco访问java服务端问题

     因SAP升级,而影响SAP访问java端的JCoServer,这这两周都在搞这些了。走了不少弯路,也收获很多,希望给有类似需求的朋友有所帮助。

Sap系统: 用SM59调整TCP/IP 下的SAP 到MBS的链接,SAP的编码由NON-UNICODE改成UNICODE后,SAP主动访问java访问有问题,连接不通。
java系统jco server端之前用的jco2.15,结果连接有问题。
一、SAP UNICODE;JAVA jco2.15
问题描述:主要是SAP升级后,根本就不支持java端jco2.15服务端。无法访问。
 java.lang.UnsupportedClassVersionError: com/sap/conn/jco/JCoException (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Exception in thread "main"
开会讨论:经过测试2.15版本后,测试结果:1、SAP的UNICODE页签里选项选择NON-UNICODE时,可以访问java服务端,但是不能传输数据;2、1、SAP的UNICODE页签里选项选择UNICODE时,根本就不能访问java jco2.15服务端。
 会议提出解决方案:一、SAP升级,不适用JCO进行数据传输,通过WebService进行数据交互。改动量太大。 二、SAP升级,java JCO2.15升级到JCO3,但是JCO3必须在JRE1.5及以上版本才能跑。需要有JRE1.5的环境。java端改动不大,不能提供新的硬件,只能现有环境使用的机子。  最终采纳第二个方案。在TIM测试机10.13.107.178这个机子上部署测试程序。


二、SAP UNICODE; JAVA jco3、Solaris9、32位系统、32位jdk
 前期准备:1、找到jco3对应的dll、so文件。确认Solaris环境下的JDK版本1.5.0_06 是否支持JCO3。以上都反馈肯定的回答。OK,开始大显身手。
 部署时遇到的问题一:Caused by: java.lang.ExceptionInInitializerError: Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
        at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:210)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:75)
        at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
        at com.sap.conn.jco.rt.StandaloneServerFactory.get(StandaloneServerFactory.java:53)
 分析:找不到sapjco3.so文件,sapjco3放的地址程序找不到,应该找系统变量中。
 解决方法:在main函数添加一下代码:System.out.println(System.getProperty("java.library.path")); 就能打印出系统变量存放地址。有多个地址。windows和solaris环境都可以用

      问题二:java.lang.UnsatisfiedLinkError: /usr/jdk/instances/jdk1.5.0/jre/lib/sparc/server/libsapjco3.so: ld.so.1: java: 致命的: /usr/jdk/instances/jdk1.5.0/jre/lib/sparc/server/libsapjco3.so: 错误的 ELF 类型: ELFCLASS64 (Possible cause: architecture word width mismatch)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
        at java.lang.Runtime.loadLibrary0(Runtime.java:822)
        at java.lang.System.loadLibrary(System.java:993)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.loadLibrary(DefaultJCoRuntime.java:444)
 分析:JCO3java服务端启动是需要调用sapjco.so连接SAP系统。但是SAP只提供了在64jre环境下运行的sapjco.so(但是有windows下的32位撒sapjco.dll)。而我们只有32位系统、32为jre环境,无论生产环境还是测试环境。
 结果:放弃Solaris,主攻windows2003sp2环境。

三、SAP UNICODE; JAVA jco3、windows2003sp2、32位系统、32位jdk
 非常不想放弃solaris,稳定啊,无奈SAP不给力,所以只能转向windows2003sp2。找了一台2007年的老破PC,模拟生产环境搭建测试环境,装系统、驱动经历无数坎坷,终于搞定测试环境,部署代码启动JCoServer,结果又失望了。
        问题一、java.lang.UnsatisfiedLinkError: sapjco3 (由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题。 )
        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:953)
        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:922)
        at java.lang.System.loadLibrary(System.java:451)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.loadLibrary(DefaultJCoRuntime.java:429)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.registerNativeMethods(DefaultJCoRuntime.java:297)
        at com.sap.conn.jco.rt.JCoRuntime.registerNatives(JCoRuntime.java:876)
        at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:948)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
        at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:41)
        at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:253)
        at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:197)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
        at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:75)
        at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
        at com.sap.conn.jco.rt.About.<init>(About.java:39)
        at com.sap.conn.jco.rt.About.main(About.java:70)
 分析,因为程序没有找到sapjco3.dll文件,由此推断是dll文件没有注册,在c:/windows/system32/下执行一下命令regsvr32 sapjco3.dll,结果还是提示“注册失败,由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题。”。重新想其他办法。按照这个帖子http://blog.csdn.net/liuyuqi520/article/details/7009113http://blog.csdn.net/billhepeng/article/details/7060133提示找到了解决方法。方法如下:
 a、 复制sapjco3.dll到c:/windows/system32/目录; b、复制 msvcr80.dll 和 msvcp80.dll 文件到目录 C:/windows/system32/; c、运行java -jar c:/erp/lib/sapjco3.jar,确认可以启动JCOserver; d、如果系统中没有vc2005 c/c++,则需要安装一个相关软件vcredist_x86.exe,用来解析sapjco3.dll文件,这个很重要,(Note: Before installing JCo, please install the latest Microsoft Visual Studio 2005 C/C++ runtime libraries as described in note 684106.)。

      问题二、Error occured on JCOSERVER01 connection null 方法二可以
com.sap.conn.jco.JCoException: (129) JCO_ERROR_SERVER_STARTUP: Server startup failed at Thu Mar 01 10:13:58 CST 2012.
This is caused by either a) erroneous server settings, b) the backend system has been shutdown, c) network problems. Will try next startup in 1 seconds.
Could not start server: Connect to SAP gateway failed
    Connection parameters: TPNAME=JCOSERVER01 GWHOST=10.13.72.8 GWSERV=sapgw00

ERROR       service '?' unknown
TIME        Thu Mar 01 10:13:58 2012
RELEASE     720
COMPONENT   NI (network interface)
VERSION     40
RC          -3
DETAIL      NiErrSet
COUNTER     2

 at com.sap.conn.jco.rt.DefaultServer.openConnection(DefaultServer.java:1226)
 at com.sap.conn.jco.rt.DefaultServer.openConnections(DefaultServer.java:1109)
 at com.sap.conn.jco.rt.DefaultServer.adjustConnectionCount(DefaultServer.java:1039)
 at com.sap.conn.jco.rt.DefaultServerManager$DispatcherWorker.run(DefaultServerManager.java:300)
 at java.lang.Thread.run(Thread.java:595)
Caused by: com.sap.conn.jco.JCoException: (129) JCO_ERROR_SERVER_STARTUP: Could not start server: Connect to SAP gateway failed
    Connection parameters: TPNAME=JCOSERVER01 GWHOST=10.13.72.8 GWSERV=sapgw00
解决:参考该帖子的方法:http://blog.csdn.net/wnowspsu/article/details/6271577 方法二证可以解决该问题,方法一没有测试。
 办法一:修改注册表
1.开始->运行->输入regedit,到HKLM_LOCAL_MACHINE/System/CurrentControlSet/Services/TCPIP/Parameters/
2.找到DatabasePath,重命名为DatabasePath_old(或者删掉也可以),然后新建可扩充字符串值,命名为DatabasePath,并填入数据%SystemRoot%/System32/drivers/etc
好,现在可以试试了,如果不行,还有下面的办法
办法二:修改services文件
到C:/Windows/System32/drivers/etc目录下,用记事本打开services,在末尾加上以下内容:
sapdp00 3200/tcp #SAP Server
sapgw00 3300/tcp #SAP Gateway
然后保存,就可以了。
(在win7下系统会提示没有权限保存这个目录的文件,你可以把文件存到其他地方,然后复制替换到C:/Windows/System32/drivers/etc目录下)

      问题三、在windows2003sp2上搭建的环境,
错误:Exception in thread "main" java.lang.RuntimeException: Unable to create the server SERVER, because of Unable to get repository
rfcexception: [null]
message:connect to SAP gateway failed
Caused by: com.sap.conn.jco.JCoException:(102)RFC_ERROR_COMMUNICATION:Connect to SAP gateway failed
connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=10.13.72.10 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) ON LOCAL HOST WIHT Unicode
ERROR internal error
 分析:找不到网关,
 解决:检查网络设置。

 

其他常见问题:
RFC接口调用SAP如果有异常会通过com.sap.mw.jco.JCO$Exception: 抛出异常
在开发中遇到的异常有如下
用户名密码可能是错误或者用户无权限,确认用户,必要时联系SAP负责人,检查用户
(103) RFC_ERROR_LOGON_FAILURE: ##.#####,####
(103) RFC_ERROR_LOGON_FAILURE: Name or password is incorrect (repeat logon)

call信息没有填写完整,检查配置文件各个SAP配置信息是否完整
(101) RFC_ERROR_PROGRAM: Missing R3NAME=... or ASHOST=... in connect_param in RfcOpenEx

ip地址失败:
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed

组权限访问 server文件没更新.
(102) RFC_ERROR_COMMUNICATION:Connect to message server failed

C:\WINNT\system32\drivers\etc

端口号错误报错信息:
(103) RFC_ERROR_LOGON_FAILURE: ## 502 ########

超时:
(103) RFC_ERROR_LOGON_FAILURE: Timeout

执行函数,函数的问题
(104) RFC_ERROR_SYSTEM_FAILURE: Error in module RSQL of the database interface.执行函数

(104) RFC_ERROR_SYSTEM_FAILURE: An error occurred when receiving a complex parameter.

(106) JCO_ERROR_RESOURCE: Trying to access row values in a table which does not have any rows yet

返回的表没有值.那个表连第一行都没有,取不到
(106) JCO_ERROR_RESOURCE: Trying to access row values in a table which does not have any rows yet

语法错误
(104) RFC_ERROR_SYSTEM_FAILURE: Syntax error in program SAPMV50A

找不到行
(106) JCO_ERROR_RESOURCE: Trying to access row values in a table which does not ha:ve any rows yet

输入参数不能插入SAP函数输入字段中.
(122) JCO_ERROR_CONVERSION: Integer '4234243' has to many digits at field PO_ITEM

 

特别感谢以下文章作者:
http://blog.csdn.net/liuyuqi520/article/details/7009113
 http://blog.csdn.net/billhepeng/article/details/7060133
http://blog.csdn.net/zhoueeee/article/details/5029741

 


 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值