Spring Boot异常:无法打开ServletContext资源[/WEB-INF/dispatcherServlet-servlet.xml]

时间:2015-12-30 08:46:56

标签: spring-mvc spring-boot weblogic weblogic12c

我已经开发了这个概念证明https://github.com/DISID/disid-proofs/tree/master/spring-boot-weblogic来测试Weblogic 12c(12.2.1)中Spring Boot应用程序的部署。

应用程序部署并成功启动,但当我尝试连接到它时(即 / accounts?number = 1234 ),会显示以下错误:

Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error 
The server encountered an unexpected condition which prevented it 
  from fulfilling the request.

日志文件有例外:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:609)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:510)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run

我错过了什么吗?

谢谢,

2 个答案:

答案 0 :(得分:15)

我找到了一个解决方法,将dispatcherServlet-servlet.xml文件放在WEB-INF下:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- Do not remove this file! -->

</beans>

答案 1 :(得分:10)

我使用spring-boot-sample-war(使用额外的weblogic.xml处理日志记录)使用WebLogic 12.2.1.0(普通新安装)重现了此问题。还尝试了最新的补丁集(WLS PATCH SET UPDATE 12.2.1.0.160419),但问题仍然存在。

出于某种原因,WebLogic决定只要您访问/上可用的应用程序就需要使用它自己的配置来创建DispatcherServlet。

我已向Oracle支持部门提出服务请求,我们会看到他们对此问题的看法。

更新:&#39;补丁23124727:无法部署弹跳靴。警告12.2.1由于JAVA.IO.FILENOTFOUNDEXCEPTION&#39;适用于Oracle WebLogic Server 12.2.1.0.0,可与spring-boot-sample-war以及更高级的应用程序一起使用。