简体   繁体   English

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

[英]Exception in thread “main” java.lang.ExceptionInInitializerError while trying to run ST312_TestMain class

I am trying to call "getOrderList" from the ST312_TestMain class. 我正在尝试从ST312_TestMain类调用“ getOrderList”。 I am getting the java.lang.ExceptionInInitializerError for the below mentioned class. 我正在获取下面提到的类的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");
        }

    }

}

The exception is as follows: 异常如下:

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

Please help me on this problem, since I am not sure how to handle the YCPContext object. 请帮我解决这个问题,因为我不确定如何处理YCPContext对象。 ("YCPContext env = new YCPContext("admin", "admin");"). (“ YCPContext env = new YCPContext(” admin“,” admin“);”)。 Thanks in advance. 提前致谢。

Request support from IBM about this. 请求IBM支持。

No matter what mistakes you may have made configuring it (if any), the Sterling code should not be throwing an NPE at you. 无论您在配置它时犯了什么错误(如果有),Sterling代码都不应向您抛出NPE。

If you are testing in local using main() method, then you should comment all the lines where you are using environment varilable. 如果要使用main()方法在本地进行测试,则应注释所有使用环境变量的行。 For your code its env variable. 对于您的代码,其env变量。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在线程“主”中获取异常java.lang.ExceptionInInitializerError异常 - Getting Exception in thread “main” java.lang.ExceptionInInitializerError Exception 线程“主”中的异常java.lang.ExceptionInInitializerError(Clojure) - Exception in thread “main” java.lang.ExceptionInInitializerError (Clojure) 线程“主”中的休眠异常java.lang.ExceptionInInitializerError - Hibernate Exception in thread “main” java.lang.ExceptionInInitializerError Eclipse - Drools - 线程“main”中的异常 java.lang.ExceptionInInitializerError - Eclipse - Drools - Exception in thread "main" java.lang.ExceptionInInitializerError 获取错误“线程“ main”中的异常java.lang.ExceptionInInitializerError” - Getting Error “Exception in thread ”main“ java.lang.ExceptionInInitializerError” Spring Error-线程“ main”中的异常java.lang.ExceptionInInitializerError - Spring Error- Exception in thread “main” java.lang.ExceptionInInitializerError 运行简单的Hibernate应用程序“线程“ main”中的异常“ java.lang.ExceptionInInitializerError”时遇到此错误 - I got this error while running simple Hibernate application “Exception in thread ”main“ java.lang.ExceptionInInitializerError” 使用log4j时出现错误“线程“ main”中的异常“ java.lang.ExceptionInInitializerError” - Error “Exception in thread ”main“ java.lang.ExceptionInInitializerError” while working with log4j 线程“主”中的异常java.lang.ExceptionInInitializerError原因:java.lang.NullPointerException - Exception in thread “main” java.lang.ExceptionInInitializerError Caused by: java.lang.NullPointerException 由 java.lang.RuntimeException 引起的线程“main”java.lang.ExceptionInInitializerError 中的异常:无法实例 KieServices - Exception in thread "main" java.lang.ExceptionInInitializerError caused by java.lang.RuntimeException: Unable to instance KieServices
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM