java - 不使用 Spring 时出现 Spring 异常

标签 java spring web-services

我在让 CDI 与 JAX-WS Web 服务实现配合使用时遇到问题。然而,在尝试调试此问题时,我在日志中看到一个我无法理解的异常。日志,异常(exception)情况是(第 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 类。我根本没有使用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

最佳答案

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

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

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

关于java - 不使用 Spring 时出现 Spring 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35004756/

相关文章:

Java java.lang.ClassNotFoundException : jade. core.migration.InterPlatformMobilityService

java - 如何在 Java Web 服务中重载方法?

android - Android应用程序如何访问集中式数据库

Spring Boot : CORS Issue

java - 使用 Keycloak 生成 token

java - Qsub 与作业脚本与输入

java - 无法接受 selenium java 中的警报 - Firefox 浏览器

java - Java 中的多消费者生产者

java - 如何在 Java 中将 LinkedHashSet 转换为 EnumSet?

spring - 扩展 RepositoryRestExceptionHandler