【问题标题】:WebLogic failing starting the application - not able to find spring config fileWebLogic 无法启动应用程序 - 无法找到 spring 配置文件
【发布时间】:2014-07-21 11:01:01
【问题描述】:

我在 web.xml 中定义了以下内容

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:p360UiSpringConfig/p360UiDispatcherServlet-servlet.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>p360UiDispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

下面是我的 web-inf 的样子:

当我在 WebLogic 中启动我的应用程序时,我收到以下错误:

错误 java.io.FileNotFoundException:无法打开 ServletContext 资源 [/WEB-INF/p360UiDispatcherServlet-servlet.xml]

问题是当我定义了 contextConfigLocation 时,为什么要在 Web-Inf 中寻找 spring 配置文件?

【问题讨论】:

    标签: java spring-mvc weblogic12c


    【解决方案1】:

    web.xml 中编辑您的contextConfigLocation,如下所示。

    编辑

    正在发生的事情是 Spring 容器正在尝试通过 &lt;Dispatcher Servlet Name&gt;-servlet.xml 在 WEB-INF 文件夹中查找上下文。这是因为您没有为调度程序 servlet p360UiDispatcherServlet 指定 &lt;init-param&gt;&lt;context-param&gt; 用于指定常见的附加上下文路径,例如 DAO、安全等。这应该可以理想地解决您的问题。请查看修改后的web.xml

    <!-- Any Common Additional Context Paths -->
    <!--<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </context-param>-->
    
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <servlet>
        <servlet-name>p360UiDispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/p360UiSpringConfig/p360UiDispatcherServlet-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    

    【讨论】:

      猜你喜欢
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-05
      • 2015-04-03
      • 1970-01-01
      • 2021-08-25
      相关资源
      最近更新 更多