Is it possibile to configure tomcat web-app context (specifically persistance manager) from in-app configuration using WebServerFactoryCustomization
e.g.:
@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> servletContainerCustomizer() {
new WebServerFactoryCustomizer<TomcatServletWebServerFactory>() {
@Override
void customize(TomcatServletWebServerFactory container) {
container.addContextCustomizers(new TomcatContextCustomizer() {
@Override
void customize(Context context) {
context.setManager(new RedissonSessionManager())
//...
}
})
}
}
}
but still deploy to a standalone tomcat?
I'm aware this configuration is more for the embedded tomcat mode but I would like to eliminate the necessity to change the context.xml
and still deploy a war to standalone tomcat.
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<Manager className="org.redisson.tomcat.RedissonSessionManager" .... />
</Context>
When I try this it does not work, it either displays:
Catalina-utility-1 o.a.c.c.StandardWrapper INFO Waiting for [1] instance(s) to be deallocated for Servlet [grailsDispatcherServlet]
or just stalls.
No. One cannot control the external tomcat from your application.
Imagine 10 applications deploy to the same Tomcat all configuring that external instance to there own liking... That would result in chaos and not to mention the security implications that come with it.
For this same reason the server.*
properties only work for embedded containers and not when deployed to an external container.