I have a Spring 4 web application (webapp-module.war) running and working locally in eclipse using Java 8, tomcat 8 and JavaConfig (no web.xml):

But when I deploy tomcat 8 (the same version that I use locally in eclipse) on a remote Ubuntu server, I get:

I checked the host and port correctly. There is no error in the log (/var/lib/tomcat8/logs/catalina.out)
Jun 21, 2016 10:32:44 PM org.apache.catalina.startup.HostConfig undeploy INFO: Undeploying context [/webapp-module] Jun 21, 2016 10:32:44 PM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive /var/lib/tomcat8/webapps/webapp-module.war Jun 21, 2016 10:32:46 PM org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Jun 21, 2016 10:32:46 PM org.apache.catalina.startup.HostConfig deployWAR INFO: Deployment of web application archive /var/lib/tomcat8/webapps/webapp-module.war has finished in 1,870 ms root@vmi63860:/var/lib/tomcat8/logs
The access log contains:
root@vmi63860:/var/log/tomcat8
Where xx.xxx.xxx.xx is the IP address of my local machine, from where I am trying to access the web application in my browser.
I looked: Spring Java configuration: deploying Tomcat without web.xml , but it really doesn't provide a solution.
Details of my project below:
Sources

Config.java
@Configuration // Marks this class as configuration // Specifies which package to scan @ComponentScan("com.samples") // Enables Spring annotations @EnableWebMvc public class Config { @Bean public UrlBasedViewResolver setupViewResolver() { UrlBasedViewResolver resolver = new UrlBasedViewResolver(); resolver.setPrefix("/WEB-INF/jsp/"); resolver.setSuffix(".jsp"); resolver.setViewClass(JstlView.class); return resolver; } }
WebInitializer.java
public class WebInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(Config.class); ctx.setServletContext(servletContext); Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1); } }
HelloController.java
@Controller public class HelloController { @RequestMapping("/") public String home() { return "index"; } @RequestMapping("/hello") public String showhello(ModelMap model) { model.addAttribute("message", "Hello Spring MVC Framework!"); return "hello"; } }
java spring eclipse spring-mvc tomcat
u123
source share