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:

ValveHandler
org.apache.catalina.valves.AccessLogValveio.undertow.server.handlers.accesslog.AccessLogHandler
org.apache.catalina.valves.ExtendedAccessLogValveio.undertow.server.handlers.accesslog.AccessLogHandler
org.apache.catalina.valves.RequestDumperValveio.undertow.server.handlers.RequestDumpingHandler
org.apache.catalina.valves.RewriteValveio.undertow.server.handlers.SetAttributeHandler
org.apache.catalina.valves.RemoteHostValveio.undertow.server.handlers.AccessControlListHandler
org.apache.catalina.valves.RemoteAddrValveio.undertow.server.handlers.IPAddressAccessControlHandler
org.apache.catalina.valves.RemoteIpValveio.undertow.server.handlers.ProxyPeerAddressHandler
org.apache.catalina.valves.StuckThreadDetectionValveio.undertow.server.handlers.StuckThreadDetectionHandler
org.apache.catalina.valves.CrawlerSessionManagerValveio.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>