I'm creating a Springboot app with OAuth2, which means I need to be able to parse a login.jsp file for users to log in through. This all works locally but on EB I get 404s for all JSP targets. The OAuth endpoints work fine on EB and I can still request tokens manually but all requests that require the users to login just result in the following webpage:
There was an unexpected error (type=Not Found, status=404).
/WEB-INF/views/login.jsp
Having looked at the debug log the only difference in the logs are the following, which to me would appear to imply that path on EB is no longer valid and it can't find the src/main/webapp within which I've put WEB-INF/views/login.jsp
On localhost:
2017-01-17 23:50:15.406 DEBUG 11872 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /home/cillian/workspace/CogTracker/target/CogTracker-0.0.1-SNAPSHOT.jar
2017-01-17 23:50:15.407 DEBUG 11872 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /home/cillian/workspace/CogTracker/target/CogTracker-0.0.1-SNAPSHOT.jar
2017-01-17 23:50:15.407 DEBUG 11872 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Document root: /home/cillian/workspace/CogTracker/src/main/webapp
On AWS ElasticBeanstalk:
2017-01-17 23:23:12.438 DEBUG 1065 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /var/app/current/application.jar
2017-01-17 23:23:12.440 DEBUG 1065 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /var/app/current/application.jar
2017-01-17 23:23:12.441 DEBUG 1065 --- [ main] .t.TomcatEmbeddedServletContainerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
So the question is, does the upload to EB require the files to be in a different location? Does the ServletContext require a specific parameter to be able to find files on EB?
For reference my WebApplicationInitializer class
public class DispatcherServletInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.scan("uk.ac");
servletContext.addListener(new ContextLoaderListener(context));
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
}
and my WebMvcConfigurerAdapter:
@Configuration
@EnableWebMvc
public class AppConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer){
configurer.enable();
}
@Override
public void addViewControllers(final ViewControllerRegistry registry){
super.addViewControllers(registry);
registry.addViewController("/login.html");
registry.addViewController("/welcome.html");
}
@Bean
public InternalResourceViewResolver viewResolver(){
final InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setViewClass(JstlView.class);
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
}