Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

IOException parsing XML document from ServletContext resource What throws this exception in my SpringBoot RESTweb service?

$
0
0

XML file is required, as the compiler says, even if it's a REST project. I' d like to intercept the "/login" call, first time on Spring Security dependency and no idea on how to handle this error. It says that an error occurs while parsing xml document, but this file doesn't exist on my project.

This is my @Configuration class:

import com.example.progettoSERVLETCONSAP.Servlet.CustomDispatcherServlet;import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;import org.springframework.boot.web.servlet.ServletRegistrationBean;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.core.Ordered;import org.springframework.web.servlet.DispatcherServlet;import org.springframework.web.servlet.handler.HandlerMappingIntrospector;@Configurationpublic class DispatcherServletConfiguration{    @Bean    public DispatcherServletPath dispatcherServletPath() {        return () -> "/";    }    @Bean    public HandlerMappingIntrospector handlerMappingIntrospector() {        return new HandlerMappingIntrospector();    }    @Bean    public ServletRegistrationBean<CustomDispatcherServlet> customDispatcherServletRegistration() {        ServletRegistrationBean<CustomDispatcherServlet> registrationBean = new ServletRegistrationBean<>(new CustomDispatcherServlet(), "/custom/*");        registrationBean.setLoadOnStartup(1);        return registrationBean;    }    @Bean    public ServletRegistrationBean<DispatcherServlet> dispatcherServletRegistration(DispatcherServlet dispatcherServlet) {        ServletRegistrationBean<DispatcherServlet> registrationBean = new ServletRegistrationBean<>(dispatcherServlet, "/");        registrationBean.setLoadOnStartup(1);        registrationBean.setOrder(Ordered.LOWEST_PRECEDENCE);        return registrationBean;    }}

This is my Servlet class, @Component:

import org.springframework.stereotype.Component;import org.springframework.web.servlet.DispatcherServlet;import jakarta.servlet.ServletException;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import java.io.IOException;@Componentpublic class CustomDispatcherServlet extends DispatcherServlet {    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, jakarta.servlet.ServletException, IOException {        if (request.getServletPath().equals("/login")) {            super.service((jakarta.servlet.http.HttpServletRequest) request, (jakarta.servlet.http.HttpServletResponse) response);        } else {            response.setStatus(HttpServletResponse.SC_NOT_FOUND);        }    }}

This is the first part of the thrown error:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource \[/WEB-INF/customDispatcherServletRegistration-servlet.xml

Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>