I have Spring based application and using programmatic approach (AbstractAnnotationConfigDispatcherServletInitializer
) for app configuration.
To make tomcat session replication work I need to 'mark' app distributable using <distributable/>
tag in web.xml
, however as I mentioned I am using programmatic style, e.g.
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 docs about how to do it using Spring configs, so my question here is that, Is it possible to have distributable app without having web.xml? I can't move all configs to the web.xml, so any help is appreciated.
There are several option you cannot set from Java based configuration, one of them is <distributable />
another is the error-pages
.
For that you still need a web.xml
, just create an as empty as possible web.xml
and only include <distributable />
. Everything else can remain in 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With