-1

I have springboot application with mvc controller (mapped to /). When this application executed directly from Idea (maven plugin is used) everything is ok. There is also not problem when this application is packaged in war file and put in external tomcat directly. But when application is packaged in jar file and executed like jar (java -jar fineName.jar) then 404 error appears (There was an unexpected error type=Not Found, status=404 /WEB-INF/pages/login.html) but the login.html file exist. Can you explain what can be a reason for this error?

@Controller
public class LoginController {

@Autowired
LoginService loginService;

@RequestMapping(value ={"/", "/login"}, method = RequestMethod.GET)
public String login() {
    return loginService.getLinkStartPage();
}

@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request, HttpServletResponse response) {
    loginService.logout(request,response);
    return "login";
}
}    

MVC config

@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter{

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
}

@Bean
public InternalResourceViewResolver viewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/pages/");
    resolver.setSuffix(".html");
    return resolver;
}

loginService.getLinkStartPage() - just return name of html file based on security authorization.

springboot - 1.5.1.RELEASE

On server side there is exception:

Bizon4ik
  • 2,604
  • 4
  • 20
  • 46

1 Answers1