Ho un'applicazione web Primavera 4 (webapp-module.war) di lavoro e in esecuzione a livello locale in Eclipse utilizzando Java 8, Tomcat 8 e JavaConfig (senza web.xml):primavera JavaConfig e Tomcat 8
Ma quando schiero a Tomcat 8 (stessa versione sto utilizzando localmente in Eclipse) su un server Ubuntu remota ottengo:
ho verificato host e la porta, che siano corrette. Non v'è alcun errore nel registro (/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
[email protected]:/var/lib/tomcat8/logs#
Il log di accesso contiene:
[email protected]:/var/log/tomcat8# cat localhost_access_log.2016-06-22.txt
xx.xxx.xxx.xx - - [22/Jun/2016:22:36:00 +0200] "GET /webapp-module/ HTTP/1.1" 404 1040
xx.xxx.xxx.xx - - [22/Jun/2016:22:36:00 +0200] "GET /favicon.ico HTTP/1.1" 404 1034
xx.xxx.xxx.xx - - [22/Jun/2016:22:36:50 +0200] "GET /webapp-module/hello HTTP/1.1" 404 1050
Dove è la xx.xxx.xxx.xx IP del mio computer locale da cui provo ad accedere all'app Web nel mio browser.
Ho dato un'occhiata a: Spring Java Config: Tomcat deploy without web.xml ma in realtà non fornisce una soluzione.
dettagli sul mio progetto di seguito:
Fonti
Config.java
@Configuration // Marks this class as configuration
// Specifies which package to scan
@ComponentScan("com.samples")
// Enables Spring's 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";
}
}
Controllare se un colpo è stato ottenuto all'interno ** localhost_access_log. *. Txt ** Tomcat all'interno ** ** tronchi cartella –
Non sei sicuro di quello che vuoi dire, ma ho aggiornato la questione con il contenuto dal più recente log di accesso sul server dopo che ho provato ad accedere all'app Web dal mio browser. Non mostra alcun errore però – u123
Potrebbero sembrare domande stupide, ma il file di guerra è denominato webapp-module? Suppongo che lo stiate eseguendo anche in un'istanza di tomcat mentre in eclissi, le versioni di tomcat corrispondono? –