Issue
I get 404 error when I deploy the war file to tomcat manually. But if I run maven build spring-boot:run
in eclipse then it works fine and I can access the app through localhost:8080.
This is the app I'm trying to run https://github.com/mokarakaya/spring-boot-multi-module-maven
Any idea why I'm getting this error?
/**
* since basePackage includes com.apiDemo.* and api module is imported, api components will also be invoked.
*/
@Configuration
@ComponentScan(basePackages = "com.*")
@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception {
SpringApplication.run(WebApplication.class, args);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("com.sun.faces.expressionFactory", "org.apache.el.ExpressionFactoryImpl");
}
}
@Piotr P. Karwasz Thanks now it works on tomcat but I can't perform any operation. The update and create button produce 405 or 404 error.
Solution
Your problem is a small variation on Why it is necessary to extend SpringBootServletInitializer
while deploying it to an external tomcat. You extend the class, but at the same time override the most important method (see the documentation of ServletContainerInitializer#onStartup
):
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("com.sun.faces.expressionFactory", "org.apache.el.ExpressionFactoryImpl");
}
You should add a call to super.onStartup
:
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("com.sun.faces.expressionFactory", "org.apache.el.ExpressionFactoryImpl");
super.onStartup(servletContext);
}
Answered By - Piotr P. Karwasz