From Tomcat Valves to Undertow Handlers in a nutshell
Undertow doesn’t support the older JBoss Web valves, however most of them can be easily migrated to Undertow handlers. Here is a list of those valves and their corresponding Undertow handler:
| Valve | Handler |
| org.apache.catalina.valves.AccessLogValve | io.undertow.server.handlers.accesslog.AccessLogHandler |
| org.apache.catalina.valves.ExtendedAccessLogValve | io.undertow.server.handlers.accesslog.AccessLogHandler |
| org.apache.catalina.valves.RequestDumperValve | io.undertow.server.handlers.RequestDumpingHandler |
| org.apache.catalina.valves.RewriteValve | io.undertow.server.handlers.SetAttributeHandler |
| org.apache.catalina.valves.RemoteHostValve | io.undertow.server.handlers.AccessControlListHandler |
| org.apache.catalina.valves.RemoteAddrValve | io.undertow.server.handlers.IPAddressAccessControlHandler |
| org.apache.catalina.valves.RemoteIpValve | io.undertow.server.handlers.ProxyPeerAddressHandler |
| org.apache.catalina.valves.StuckThreadDetectionValve | io.undertow.server.handlers.StuckThreadDetectionHandler |
| org.apache.catalina.valves.CrawlerSessionManagerValve | io.undertow.servlet.handlers.CrawlerSessionManagerHandler |
It is possible to do a migration of the older web legacy subsystem configuration and related persisted data by invoking the legacy subsystem’s migrate operation, using the management CLI:
/subsystem=web:migrate
An example: using a Request Dumping Handler
Supposing you want to migrate the old RequestDumperValve. The equivalent class in undertow is io.undertow.server.handlers.RequestDumpingHandler.
You can install it using WildFly CLI as follows:
batch
/subsystem=undertow/configuration=filter/custom-filter=request-logging-filter:add(class-name=io.undertow.server.handlers.RequestDumpingHandler, module=io.undertow.core)
/subsystem=undertow/server=default-server/host=default-host/filter-ref=request-logging-filter:add
run-batch
That will result in the following configuration:
<subsystem xmlns="urn:jboss:domain:undertow:12.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other" statistics-enabled="${wildfly.undertow.statistics-enabled:${wildfly.statistics-enabled:false}}">
...
<server name="default-server">
...
<host name="default-host" alias="localhost">
...
<filter-ref name="request-dumper"/>
</host>
</server>
...
<filters>
...
<filter name="request-dumper" module="io.undertow.core"
class-name="io.undertow.server.handlers.RequestDumpingHandler"/>
</filters>
</subsystem>
Recommended Articles
Enhance Your Java Applications with JBoss Undertow: A Comprehensive Guide
Learn how to embed JBoss Undertow in your applications and leverage its high-performance features for better web server capabilities. #Java #Middleware #CloudNative
Get Started with Undertow Web Server in WildFly - Master the Boss
Learn how to deploy and use Undertow Web server as a fast and light Java Web server based on non-blocking IO. Deploying Undertow is easy, but setting it up correctly requires understanding of the framework version, dependencies, and configuration.
Create a Custom Undertow Handler for WildFly using Java
Learn how to create a custom Undertow handler in Java, package it as a WildFly module, and deploy it on WildFly.
Configure Undertow Filters on WildFly 31 for Custom HTTP Handling
Learn how to create a custom Undertow Filter in WildFly 31, including connection limit and gzip filters, and implement your own filter for capturing HostName requests.