首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >JCO_ERROR_RESOURCE:目的地ABAP_AS_WITHOUT_POOL不存在.通过JCo连接时出错

JCO_ERROR_RESOURCE:目的地ABAP_AS_WITHOUT_POOL不存在.通过JCo连接时出错
EN

Stack Overflow用户
提问于 2019-05-20 12:40:59
回答 2查看 2.9K关注 0票数 0

我正在开发一个Java应用程序,它需要从我们位于SAP表中的SAP系统中获取数据。我试图使用SAPJavaConnector3.x将SW与SAP连接起来,但我在目的地方面遇到了麻烦。

我使用了SAP连接器附带的代码示例。

代码语言:javascript
运行
复制
public class CustomDestinationDataProvider {

static class MyDestinationDataProvider implements DestinationDataProvider {
    private DestinationDataEventListener eL;
    private HashMap<String, Properties> secureDBStorage = new HashMap<String, Properties>();

    public Properties getDestinationProperties(String ABAP_AS) {
        try {
            //read the destination from DB
            Properties p = secureDBStorage.get(ABAP_AS);

            if(p!=null) {
                //check if all is correct, for example
                if(p.isEmpty())
                    throw new DataProviderException(DataProviderException.Reason.INVALID_CONFIGURATION, "destination configuration is incorrect", null);

                return p; 
                }

            return null; 
            } catch(RuntimeException re) {
            throw new DataProviderException(DataProviderException.Reason.INTERNAL_ERROR, re);
        }
    }

    //An implementation supporting events has to retain the eventListener instance provided
    //by the JCo runtime. This listener instance shall be used to notify the JCo runtime
    //about all changes in destination configurations.
    public void setDestinationDataEventListener(DestinationDataEventListener eventListener) {
        this.eL = eventListener;
    }

    public boolean supportsEvents() {
        return true;
    }

    //implementation that saves the properties in a very secure way
    void changeProperties(String ABAP_AS, Properties properties) {
        synchronized(secureDBStorage) {
            if(properties==null) {
                if(secureDBStorage.remove(ABAP_AS)!=null)
                    eL.deleted(ABAP_AS);
            } else {
                secureDBStorage.put(ABAP_AS, properties);
                eL.updated(ABAP_AS); // create or updated
            }
        }
    }
} // end of MyDestinationDataProvider

//business logic
void executeCalls(String ABAP_AS) {
    JCoDestination dest;
    try {
        dest = JCoDestinationManager.getDestination(ABAP_AS);
        dest.ping();
        System.out.println("Destination " + ABAP_AS + " works");
    } catch(JCoException e) {
        e.printStackTrace();
        System.out.println("Execution on destination " + ABAP_AS + " failed");
    }
}

static Properties getDestinationPropertiesFromUI() {
    //adapt parameters in order to configure a valid destination
    Properties connectProperties = new Properties();
    connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "XXX");
    connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "XX");
    connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "XXX");
    connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "XXX");
    connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "XXX");
    connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "XX");
    createDestinationDataFile(ABAP_AS, connectProperties);
    return connectProperties;
}

static void createDestinationDataFile(String ABAP_AS, Properties connectProperties) {
    File destCfg = new File(ABAP_AS + ".jcoDestination");
    try {
        FileOutputStream fos = new FileOutputStream(destCfg, false);
        connectProperties.store(fos, "for tests only!");
        fos.close();
    } catch (Exception e) {
        throw new RuntimeException("Unable to create the destination files", e);
    }
} 

}

这是我从NetBeans获得的错误消息:

目标com.sap.conn.jco.rt.DefaultDestinationManager.update(DefaultDestinationManager.java:217)在com.sap.conn.jco.rt.DefaultDestinationManager.searchDestination(DefaultDestinationManager.java:382) at com.sap.conn.jco.rt.DefaultDestinationManager.getDestinationInstance(DefaultDestinationManager.java:100)的com.sap.conn.jco.JCoException:(106) JCO_ERROR_RESOURCE: does ABAP_AS_WITHOUT_POOL上不存在在com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:104) at jcotest2.CustomDestinationDataProvider.executeCalls(CustomDestinationDataProvider.java:92) at jcotest2.Main.main(Main.java:39) 成功构建(总时间:2秒)

EN

回答 2

Stack Overflow用户

发布于 2019-09-17 13:01:03

看起来您的代码将登录数据保存在HashMap "secureDBStorage“中。你把这个HashMap填在哪里?

另外:如果您使用的是一个createDestinationDataFile而不是一个文件,那么您需要“HashMap ()”方法做什么呢?

编辑:由于这篇文章被评论删除了,我现在正在努力使它更加精确。因此,您的代码有两个问题:

  1. 您将后端系统的登录参数保存在名为"secureDBStorage“的secureDBStorage中,但没有为名为"ABAP_AS_WITHOUT_POOL”的系统/目的地填充此映射。
  2. 您的代码仍然包含"createDestinationDataFile()“方法,该方法可能是从示例程序复制的,然后忘记了删除。由于您的程序使用HashMap来存储登录参数,而不是文件系统,所以可以删除此方法。(只会混淆程序。)
票数 1
EN

Stack Overflow用户

发布于 2019-06-20 23:23:17

在调用目标之前,您应该在的Configuration (NWA管理器)中创建它,然后只调用它。

nwpi711/7.1.1/enUS/07/0d27932264284b883dab13ce1008a6/frameset.htm

以下是样本:

代码语言:javascript
运行
复制
static String ABAP_AS = "WD_MODELDATA_DEST";

PrintWriter out = response.getWriter();
     JCoDestination destination;
    try {
        destination = JCoDestinationManager.getDestination(ABAP_AS);
        out.println("Attributes:");
        out.println(destination.getAttributes());
        out.println();
    } catch (JCoException e) {
        e.printStackTrace();
        out.println(e.getMessage());
    }

我不知道您在代码中填充ABAP_AS变量的位置,就像在示例中那样。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56221250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档