0

我试图从 ST312_TestMain 类中调用“getOrderList”。我得到了下面提到的类的 java.lang.ExceptionInInitializerError 。

package com.Main;

import org.w3c.dom.Document;
import com.yantra.ycp.core.YCPContext;
import com.Main.XMLUtil;
import com.Main.SterlingUtil;

public class ST312_TestMain {
    public static void main(String[] args) throws Exception {

        String ServiceName = "getOrderList";
        String sServiceFlag = "N";
        Document dTemplate = null;
        //ServiceName = "SendDN";
        //sServiceFlag = "Y";
        Document inputXML=null;
        inputXML = XMLUtil.getDocument("<Order OrderHeaderKey='201407181105267340509' />");
        //inputXML = XMLUtil.getXmlFromFile("src/Test.xml");
        dTemplate = XMLUtil.getDocument("<Order OrderHeaderKey='' OrderNo=''/>");
        if (args.length == 3) {
            ServiceName = args[0];
            sServiceFlag = args[1].equals("Y") ? "Y" : "N";
            inputXML = XMLUtil.getXmlFromFile(args[2]);
        } else {
            System.out
            .println("Usage: TestMain <API/Service Name> <API/Service(N/Y)> <Input XML File>");
            System.out
            .println("No Input received using preset XML to call preset Service");
            System.out.println("Service Name=" + ServiceName);
        }
        ***YCPContext env = new YCPContext("admin", "admin");***
        System.out.println("Input XML \n" + XMLUtil.getXmlString(inputXML));

        try {           
            Document outputXML = null;
            if ("Y".equals(sServiceFlag)) {
                outputXML = SterlingUtil.callService(env, inputXML, ServiceName, null);
            } else {
                outputXML = SterlingUtil.callAPI(env, inputXML, ServiceName, dTemplate);
            }

            env.commit();
        } catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("Service Invocation Failed");
        }

    }

}

例外情况如下:

Usage: TestMain <API/Service Name> <API/Service(N/Y)> <Input XML File>
No Input received using preset XML to call preset Service
Service Name=getOrderList
log4j:WARN No appenders could be found for logger (com.yantra.ycp.core.YCPContext).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.sterlingcommerce.woodstock.util.frame.Manager.getProperty(Manager.java:1365)
    at com.yantra.yfc.util.YFCConfigurator.setStandalone(YFCConfigurator.java:37)
    at com.yantra.yfs.core.YFSSystem.init(YFSSystem.java:62)
    at com.yantra.yfs.core.YFSSystem.<clinit>(YFSSystem.java:47)
    at com.yantra.ycp.core.YCPContext.<init>(YCPContext.java:288)
    at com.yantra.ycp.core.YCPContext.<init>(YCPContext.java:276)
    at com.Main.ST312_TestMain.main(ST312_TestMain.java:31)
Caused by: java.lang.NullPointerException
    at com.sterlingcommerce.woodstock.util.frame.log.base.SCILogBaseConfig.doConfigure(SCILogBaseConfig.java:35)
    at com.sterlingcommerce.woodstock.util.frame.log.LogService.<clinit>(LogService.java:110)
    ... 7 more

请帮我解决这个问题,因为我不确定如何处理 YCPContext 对象。("YCPContext env = new YCPContext("admin", "admin");")。提前致谢。

4

3 回答 3

0

请求 IBM 对此提供支持。

无论您在配置它时可能犯了什么错误(如果有的话),Sterling 代码都不应该向您抛出 NPE。

于 2014-10-04T12:52:30.190 回答
0

如果您在本地使用 main() 方法进行测试,那么您应该注释您使用环境变量的所有行。对于您的代码,它的环境变量。

于 2014-11-17T17:31:34.573 回答
0

可能您不会将数据库驱动程序 jar 添加到您的项目构建路径中... 例如对于 DB2 数据库,必须添加 db2jcc.jar 对于 Oracle 数据库,必须添加 ojdbc.jar

于 2016-02-09T16:19:23.667 回答