从Weblogic12c(12.1.3)移至weblogic12cR2(12.2.1)时,基于注释/java配置的应用程序开始查找xml配置文件 [英] Annotation/java config based application starts to look for xml config file when moved from weblogic12c(12.1.3) to weblogic12cR2 (12.2.1)

查看:583
本文介绍了从Weblogic12c(12.1.3)移至weblogic12cR2(12.2.1)时,基于注释/java配置的应用程序开始查找xml配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的春季java-config应用程序打包为war在weblogic 12.1.3上运行时没有问题,因此我尝试将相同war部署到weblogic 12.2.1中,这会导致java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/DispatcherServlet-servlet.xml]. 似乎即使在war相同的情况下,DispatcherServlet servlet还是使用XmlWebApplicationContext(默认值)而不是12.2.1中的AnnotationConfigEmbeddedWebApplicationContext初始化. 有人知道自上一版本以来weblogic实施中发生了什么更改吗?

My spring java-config application packed as war runs wihout problem on weblogic 12.1.3 so I tried to deploy same war into weblogic 12.2.1 where it causes java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/DispatcherServlet-servlet.xml]. It seems like DispatcherServlet servlet is initialized with XmlWebApplicationContext (default one) instead of AnnotationConfigEmbeddedWebApplicationContext in 12.2.1 even when war is the same. Has someone any idea what was changed in weblogic implementation since previous version what is causing this problem?

使用相同的war:

  • 在WLS 12.1.3中,它可以正常工作,应用程序使用批注/java进行配置
  • 在WLS 12.2.1中,同一应用程序会在某个时候寻找xml配置,而不是像12.1.3中那样使用注解/java对其进行配置.

推荐答案

出现相同的问题.我猜WebLogic 12.2.1出了点问题.

Had the same problem. I guess there is something wrong with WebLogic 12.2.1.

尝试为Spring servlet 手动设置上下文类,如下所示:

Try to manually set context class for Spring servlet, like so:

public class ApplicationInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext container) throws ServletException {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        // <some context configuration>

        ServletRegistration.Dynamic spring = container.addServlet("Spring", new DispatcherServlet(context));
        // <some servlet configuration>

        // Here, set desired context class using 'contextClass' parameter.
        spring.setInitParameter("contextClass", context.getClass().getName());

        container.addListener(new ContextLoaderListener(context));
    }

}

一切都会再次正常:)

这篇关于从Weblogic12c(12.1.3)移至weblogic12cR2(12.2.1)时,基于注释/java配置的应用程序开始查找xml配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆