尝试运行ST312_TestMain类时线程“main”java.lang.ExceptionInInitializerError中的异常

时间:2014-10-04 12:29:55

标签: java ibm-sterling

我想打电话给#34; getOrderList"来自ST312_TestMain类。我收到了下面提到的类的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对象。 (&#34; YCPContext env = new YCPContext(&#34; admin&#34;,&#34; admin&#34;);&#34;)。提前致谢。

3 个答案:

答案 0 :(得分:0)

请求IBM提供支持。

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

答案 1 :(得分:0)

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

答案 2 :(得分:0)

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