我运行 SAP Java Connector 自带的 SimpleCall 例子程序时,遇到如下错误消息:
Exception in thread "main" com.sap.conn.jco.JCoException: (102) JCO_ERROR_COMMUNICATION: Initialization of repository destination ABAP_AS1 failed: Connect to SAP gateway failed
connection parameters: TYPE=A DESTINATION=ABAP_AS1 ASHOST=abap_host_name SYSNR=00 PCS=1 SERIALIZATION_FORMAT=columnBased NETWORK=LAN
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR hostname 'abap_host_name' unknown
TIME Tue Oct 25 14:07:48 2022
RELEASE 753
COMPONENT NI (network interface)
VERSION 40
RC -2
MODULE D:/depot/bas/753_REL/src/base/ni/ninti.c
LINE 898
DETAIL NiPGetHostByName: 'abap_host_name' not found
SYSTEM CALL getaddrinfo
COUNTER 2
at com.sap.conn.jco.rt.RfcDestination.getSystemID(RfcDestination.java:1560)
at com.sap.conn.jco.rt.RepositoryManager.getRepository(RepositoryManager.java:28)
at com.sap.conn.jco.rt.RfcDestination.initRepository(RfcDestination.java:1464)
at com.sap.conn.jco.rt.RfcDestination.getRepository(RfcDestination.java:1846)
at com.sap.conn.jco.rt.RfcDestination.getRepository(RfcDestination.java:40)
at com.sap.conn.jco.examples.client.beginner.SimpleCall.main(SimpleCall.java:23)
Caused by: com.sap.conn.jco.JCoException: (102) JCO_ERROR_COMMUNICATION: Connect to SAP gateway failed
connection parameters: TYPE=A DESTINATION=ABAP_AS1 ASHOST=abap_host_name SYSNR=00 PCS=1 SERIALIZATION_FORMAT=columnBased NETWORK=LAN
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR hostname 'abap_host_name' unknown
TIME Tue Oct 25 14:07:48 2022
RELEASE 753
COMPONENT NI (network interface)
VERSION 40
RC -2
MODULE D:/depot/bas/753_REL/src/base/ni/ninti.c
LINE 898
DETAIL NiPGetHostByName: 'abap_host_name' not found
SYSTEM CALL getaddrinfo
COUNTER 2
(remote system is [
at com.sap.conn.jco.rt.AbstractConnection.generateJCoException(AbstractConnection.java:624)
at com.sap.conn.jco.rt.ClientConnection.connectInternal(ClientConnection.java:633)
at com.sap.conn.jco.rt.ClientConnection.connect(ClientConnection.java:1201)
at com.sap.conn.jco.rt.RepositoryConnection.connect(RepositoryConnection.java:188)
at com.sap.conn.jco.rt.PoolingFactory.init(PoolingFactory.java:116)
at com.sap.conn.jco.rt.ConnectionManager.createFactory(ConnectionManager.java:461)
at com.sap.conn.jco.rt.DefaultConnectionManager.createFactory(DefaultConnectionManager.java:24)
at com.sap.conn.jco.rt.ConnectionManager.getFactory(ConnectionManager.java:400)
at com.sap.conn.jco.rt.RfcDestination.getSystemID(RfcDestination.java:1542)
... 5 more
Caused by: RfcException raised by system [
message: Connect to SAP gateway failed
connection parameters: TYPE=A DESTINATION=ABAP_AS1 ASHOST=abap_host_name SYSNR=00 PCS=1 SERIALIZATION_FORMAT=columnBased NETWORK=LAN
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR hostname 'abap_host_name' unknown
TIME Tue Oct 25 14:07:48 2022
RELEASE 753
COMPONENT NI (network interface)
VERSION 40
RC -2
MODULE D:/depot/bas/753_REL/src/base/ni/ninti.c
LINE 898
DETAIL NiPGetHostByName: 'abap_host_name' not found
SYSTEM CALL getaddrinfo
COUNTER 2
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
at com.sap.conn.rfc.engine.RfcIoControl.error_end(RfcIoControl.java:234)
at com.sap.conn.rfc.engine.RfcIoControl.ab_rfcopen(RfcIoControl.java:125)
at com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:77)
at com.sap.conn.jco.rt.ClientConnection.connectInternal(ClientConnection.java:597)
... 12 more
这是因为 JCO 项目文件夹下 ABAP_AS1.jcoDestination
文件的 jco.client.ashost
字段,仍然使用了默认的 abap_host_name
值(我们在错误消息里可以观察到这个值)
这里涉及到 destination 的概念。
JCoDestination 标识函数调用的物理目的地。 它包含连接到 SAP 系统所需的所有属性。
注意:JCoDestination 只是一个配置实例,其中包含 JCo 运行时创建连接所需的所有信息。它本身不会创建或保持任何连接。如果由目标配置定义,JCo 运行时会创建连接并将它们汇集起来。
目标 BACK 仅在 JCo RFC 服务器场景中可用,在发送 RFC 请求的时间点和返回 RFC 响应的时间点之间。
Destination 的类型:
- 3 - 使用未指定登录方法的 ABAP 系统的目的地
- A - 使用直接应用程序服务器主机登录的 ABAP 系统的目标
- B - 具有消息服务器驱动的负载平衡登录的 ABAP 系统的目的地
- E - 外部 RFC 服务器程序的目的地
- R - 已注册 RFC 服务器程序的目的地
- N - SAP Cloud Platform 中使用未指定登录方法的本地 ABAP 系统的目的地