Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot exception: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]

I have developed this proof of concept https://github.com/DISID/disid-proofs/tree/master/spring-boot-weblogic to test the deployment of Spring Boot applications in Weblogic 12c (12.2.1).

The application deploys and starts successfully, but when I try to connect to it (i.e. /accounts?number=1234) the error below is shown:

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.

And the log file has the exception:

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

Did I miss something?

Thanks,

like image 264
eruiz Avatar asked Dec 30 '15 08:12

eruiz


2 Answers

I've reproduced this issue with WebLogic 12.2.1.0 (plain new install) using spring-boot-sample-war (with an additional weblogic.xml to handle logging). Also tried the latest patchset (WLS PATCH SET UPDATE 12.2.1.0.160419), but the issue remains.

For some reason WebLogic decides it needs to create the DispatcherServlet using it's own configuration as soon as you access the application available on /.

I've put in a service request to Oracle Support and we'll see what they think about this issue.

Update: 'Patch 23124727: CANNOT DEPLOY SPRING BOOT .WAR ON 12.2.1 DUE TO JAVA.IO.FILENOTFOUNDEXCEPTION' is available for Oracle WebLogic Server 12.2.1.0.0 and works with both the spring-boot-sample-war as well as a more advanced application.

like image 181
Øyvind Horneland Avatar answered Oct 18 '22 19:10

Øyvind Horneland


I found a workaround putting a dummy dispatcherServlet-servlet.xml file under 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>
like image 24
Robert Hume Avatar answered Oct 18 '22 20:10

Robert Hume