gpt4 book ai didi

java - 自定义 ContextLoaderListener 类在 Websphere 中不起作用

转载 作者:行者123 更新时间:2023-12-01 13:40:43 24 4
gpt4 key购买 nike

自定义 ContextLoaderListener 类在 Websphere 中不起作用,并且引发以下错误。在 Tomcat、JBoss、Weblogic 中同样可以正常工作。

java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

我的自定义上下文加载器类如下所示:

public class CustomContextListener extends ContextLoaderListener {
//implemented contextInitized() and contextDestroyed() methods
}

在web.xml中添加如下:

<listener>
<listener-class>com.comp.app.context.CustomContextListener</listener-class>
</listener>

有人可以帮我解决这个错误吗?

更新:在日志中发现以下错误。

 00000026 DispatcherSer E org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name configMgr: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: xxxx; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [xxxxxx] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

最佳答案

ContextLoaderListener 的重点在于其 contextInitialized() 方法在 ServletContext 中初始化和注册 WebApplicationContext 。如果您重写了此方法而不调用 super 实现,则它将不会注册任何 WebApplicationContext

关于java - 自定义 ContextLoaderListener 类在 Websphere 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20811960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com