0

I tried looking for a thread that could fix my issue. this one doesn't work for me:

Spring Boot, Java Config - No mapping found for HTTP request with URI [/...] in DispatcherServlet with name 'dispatcherServlet'

I'm using WebSecurityConfigurerAdapter and HandlerInterceptor

this is the content of my web security

@Override
protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        http.authorizeRequests()
            .antMatchers("/static/**"
                , "/css/**"
                , "/js/**"
                , "/scss/**"
                , "/fonts/**"
                , "/emails/**"
                , "/*.css"
                , "/*.js"
                , "/*.scss"
                , "/*.eot"
                , "/*.svg"
                , "/*.ttf"
                , "/*.woff*"
                , "/*.otf"
                , "/*.ico"
                , ForgotPasswordController.URL.FORGOT_PASS
                , ForgotPasswordController.URL.RESET_PASS
                , LoginController.URL.REGISTER
                , LoginController.URL.LOGIN
                , LoginController.URL.ROOT)
            .permitAll()
            .anyRequest()
            .access(getAllRoles())
            .and().formLogin()
            .loginPage("/login").permitAll()
            .usernameParameter("userId")
            .passwordParameter("pass")
            .failureHandler(authenticationFailureController)
            .defaultSuccessUrl("/home", true)
            .loginProcessingUrl("/login_processing").and()
            .exceptionHandling().accessDeniedPage("/access-forbidden");
  }

It works fine, but when i tried to add a HandlerInterceptor (for audit trail purposes), it doesn't load any resource file at all, even though i added permitAll() to those resource file in my websecurity config

here's my Handler Interceptor:

@Service
public class OAuthSessionInterceptor implements HandlerInterceptor {
    private static final Logger logger = LoggerFactory.getLogger(OAuthSessionInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        logger.error("--------- preHandle ---------");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
        logger.error("--------- postHandle ---------");
    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
        logger.error("--------- afterCompletion ---------");
    }
}

here's what it returns, it gives 404 not found for the resource files.

enter image description here

here's the project structure, i focused on the resources part:

enter image description here

KennethC
  • 746
  • 2
  • 10
  • 27

0 Answers0