I am working with Vaadin 7.7 and SpringFramework with Maven.
The code I made worked last time, but today it does not work.
The error message is Failed to load bootstrap javascript : ./VAADIN/vaadinBootstrap.js?v=7.7.0
.
I have searched the internet, and found this. Vaadin's vaadinBoootstrap.js
I says I need session-config
in web.xml
. However, I do not have web.xml
since I am using servlet version 3.X
. So I add this statement to my WebApplicationInitializer
. My code is below.
public class FarmInitializer implements WebApplicationInitializer {
static private Logger logger = LoggerFactory.getLogger(Logger.class);
@Override
public void onStartup(ServletContext arg0) throws ServletException {
System.out.println("=== Starts ===");
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(ServletConfig.class);
ctx.register(FileConfig.class);
ctx.register(DBConfig.class);
//Solution of vaadinBootstrap.js?
Set<SessionTrackingMode> sessionConfigSet = new HashSet<>();
sessionConfigSet.add(SessionTrackingMode.COOKIE);
arg0.setSessionTrackingModes(sessionConfigSet);
arg0.addListener(new ContextLoaderListener(ctx));
registerServlet(arg0);
System.out.println("=== Ends ===");
}
private void registerServlet(ServletContext ctx){
Dynamic dispatcher = ctx.addServlet("vaadin", SpringVaadinServlet.class);
dispatcher.addMapping("/");
dispatcher.setLoadOnStartup(0);
logger.info("=== DONE ===");
}
}
But It does not work still. Is there any solution for this problem?
My server is Tomcat 7.X
. Thanks for your help!
have you tried to map your vaadin servlet as /* (instead of /) or to add a mapping for /VAADIN/*
dispatcher.addMapping("/*");