Labeling an application without the web.xml extension for Tomcat session replication

I have a Spring based application and using a software approach ( AbstractAnnotationConfigDispatcherServletInitializer ) to configure the application.

To make tomcat session replication, I need to "mark" the distribution application using the <distributable/> in web.xml , however, as I said, I use a program style, for example

 public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { String activeProfile = activeProfile(); if (isNotEmpty(activeProfile)) { servletContext.setInitParameter("spring.profiles.active", activeProfile); } super.onStartup(servletContext); } } 

I can't find any documents on how to do this using Spring configs, so my question here is, is it possible to have a redistributable application without web.xml? I cannot move all configs to web.xml, so any help would be appreciated.

+6
source share
3 answers

There are several parameters that you cannot set from a Java-based configuration, one of which <distributable /> other is error-pages .

To do this, you still need web.xml , just create as little web.xml as possible and enable <distributable /> . Everything else can remain in a Java based configuration.

 <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <distributable /> </web-app> 
+4
source

It seems like an answer has already been given here ... Mixing web.xml and AbstractAnnotationConfigDispatcherServletInitializer in Spring If I don't understand the question / answer.

0
source

Unable to configure the cluster programmatically using Spring. One solution is to combine a configuration based on XML and Java. For Web.xml entries to be supported. An example is here for this.

0
source

All Articles