不使用Spring时获得Spring异常

时间:2016-01-25 23:59:42

标签: java spring web-services

我遇到了使CDI与JAX-WS Web服务实现一起工作的问题。但是,在尝试调试此问题时,我在日志中看到一个异常,我无法理解。日志和例外情况是(从'[警告]'开始的第5行:

Launching defaultServer (WebSphere Application Server 8.5.5.6/wlp-1.0.9.cl50620150610-1749) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_79-b15 (en_US)
[AUDIT   ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT   ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.6/lafiles/en.html
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. 
[WARNING ] CWNEN0047W: Resource annotations on the fields of the path.not.important.external.service.eNC3BusinessWebServiceImpl class will be ignored. The annotations could not be obtained because of the exception : java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9090/eNC3BusinessWebService/
[AUDIT   ] CWWKZ0001I: Application eNC3BusinessWebService_EAR started in 2.841 seconds.
[AUDIT   ] CWWKF0012I: The server installed the following features: [jaxws-2.2, cdi-1.2, servlet-3.1, jndi-1.0, javaMail-1.5, jaxb-2.2].
[AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.

我很困惑为什么会加载任何弹簧类。我根本不使用Spring。这是JAX-WS Web服务的纯Java 7实现。以下是我的实现类:

package path.not.important.external.service;

import java.util.List;

import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.soap.SOAPException;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import path.not.important.external.domain.DemographicBean;
import path.not.important.external.domain.ErrorInfo;
import path.not.important.external.domain.SubmissionValidationResults;
import path.not.important.internal.client.FileSubmissionServiceHandler;
import path.not.important.rules.submission.BRSubmissionService;
import path.not.important.internal.SubmissionFormData;
import path.not.important.plugin.IResult;
import path.not.important.plugin.SubmissionResult;

@WebService(serviceName="eNC3BusinessWebService")
public class eNC3BusinessWebServiceImpl
{

    @WebMethod
    public SubmissionValidationResults xmlValidation(String xml, String submissionType, String schemaVersion)
            throws SOAPException
    {
        logger.info("--- Validating Incomming Form XML ---");

        logger.info("Received Payload: XML [" + xml + "]");
        logger.info("SubmissionType [" + submissionType + "]");
        logger.info("SchemaVersion [" + schemaVersion + "]");

        return results;
    }

    @WebMethod
    public SubmissionValidationResults flatFileValidation(String filename, byte[] file) throws SOAPException
    {
        logger.info("--- Converting and Validating Incomming Form Flat File ---");

        logger.info("Validating flat file: " + filename);
        logger.info("file size: " + file.length);
        logger.info("file: " + file.toString());

        return results;
    }

    @WebMethod
    public String finalNC3FormSubmission(DemographicBean demographicData, List<SubmissionFormData> nc3,
            List<SubmissionFormData> irsW2, List<SubmissionFormData> irs1099) throws SOAPException
    {
        logger.info("Executing final submission of website form data...");

        return messageID;
    }

    @Inject
    private FileSubmissionServiceHandler fileSubmissionServiceHandler;

    @Inject
    private BRSubmissionService brSubmissionService;

    public static final Logger logger = LogManager.getLogger(eNC3BusinessWebServiceImpl.class);
}

我不知道我的CDI问题和这个问题是否相关,但我试图消除问题的任何其他原因。我的CDI问题记录在这里: JAX-WS and CDI not working together on WAS Liberty Profile 8.5.5.6

1 个答案:

答案 0 :(得分:0)

好的,我终于找到了问题的原因。这也回答了我的另一个问题。

CDI正在加载名为BRSubmissionService的对象。弹簧异常会中断CDI加载。由于CDI无法完成,因此不会发生剩余的CDI注入,并且我的FileSubmissionService对象未加载,导致我的空指针异常。

解决方案是修复位于另一个jar中的BRSubmissionService对象内的spring错误,遗憾的是我从另一个开发人员那里继承了该错误。这就是生活。