tomcat – Provider class org.jboss.resteasy.plugins.providers.* is already registered. 2nd registration is being ignored

Maven-WebApp, developed in Eclipse, runs on Tomcat 8.5 (not EE), Java 1.8.

I had to implement a REST-API and Swagger as documentation for OAS3. So I added RestEasy and Swagger (POM). Also Swagger-UI, which get´s integrated in the WAR. App runs well. Swagger also, I can use “Try out” and get the correct response. So all is fine.

But when I start the Tomcat, there are the following entries in the Log
(for better reading here, I made a * and list the classes)

2022-06-23 16:50:33.885 [unknown:unknown:unknown] WARN  o.j.r.r.i18n [registerProvider:1818] RESTEASY002155: Provider class org.jboss.resteasy.plugins.providers.*
    -InputStreamProvider 
    -ReaderProvider 
    -FormUrlEncodedProvider
    -jackson.UnrecognizedPropertyExceptionHandler
    -StreamingOutputProvider
    -ByteArrayProvider 
    -DefaultBooleanWriter
    -sse.SseEventSinkInterceptor 
    -DefaultTextPlain 
    -IIOImageProvider
    -DataSourceProvider 
    -JaxrsServerFormUrlEncodedProvider 
    -FileProvider 
    -StringTextStar
    -sse.SseEventProvider
    -DocumentProvider 
    -SourceProvider
    -JaxrsFormProvider 
    -FileRangeWriter 
    -DefaultNumberWriter 
    -jackson.ResteasyJackson2Provider
    -jackson.PatchMethodFilter
2022-06-23 16:50:33.925 [unknown:unknown:unknown] WARN  o.j.r.r.i18n [registerProvider:1818] RESTEASY002155: Provider class org.jboss.resteasy.plugins.*
    -interceptors.encoding.MessageSanitizerContainerResponseFilter

mvn dependency:tree

[←[1;33mWARNING←[m] The artifact org.hibernate:hibernate-validator:jar:6.0.13.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.0.13.Final
[←[1;33mWARNING←[m] The artifact org.hibernate:hibernate-validator-cdi:jar:6.0.13.Final has been relocated to org.hibernate.validator:hibernate-validator-cdi:jar:6.0.13.Final
[←[1;34mINFO←[m] de.XXXXX.intern:XXXXX:war:1.0.11
[←[1;34mINFO←[m] +- com.itextpdf:itextpdf:jar:5.3.4:compile
[←[1;34mINFO←[m] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[←[1;34mINFO←[m] +- javax.faces:javax.faces-api:jar:2.3:compile
[←[1;34mINFO←[m] +- org.glassfish:javax.faces:jar:2.4.0:compile
[←[1;34mINFO←[m] |  - javax.el:javax.el-api:jar:3.0.1-b04:compile
[←[1;34mINFO←[m] +- org.glassfish:javax.el:jar:3.0.0:compile
[←[1;34mINFO←[m] +- javax.validation:validation-api:jar:2.0.1.Final:compile
[←[1;34mINFO←[m] +- org.primefaces:primefaces:jar:6.2:compile
[←[1;34mINFO←[m] +- org.primefaces.extensions:primefaces-extensions:jar:6.2.11:compile
[←[1;34mINFO←[m] |  - com.google.code.gson:gson:jar:2.8.2:compile
[←[1;34mINFO←[m] +- org.hibernate:hibernate-core:jar:5.4.0.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[←[1;34mINFO←[m] |  +- javax.persistence:javax.persistence-api:jar:2.2:compile
[←[1;34mINFO←[m] |  +- org.javassist:javassist:jar:3.24.0-GA:compile
[←[1;34mINFO←[m] |  +- antlr:antlr:jar:2.7.7:compile
[←[1;34mINFO←[m] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile
[←[1;34mINFO←[m] |  +- com.fasterxml:classmate:jar:1.3.4:compile
[←[1;34mINFO←[m] |  +- javax.activation:javax.activation-api:jar:1.2.0:compile
[←[1;34mINFO←[m] |  +- org.dom4j:dom4j:jar:2.1.1:compile
[←[1;34mINFO←[m] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.0.Final:compile
[←[1;34mINFO←[m] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[←[1;34mINFO←[m] |  - org.glassfish.jaxb:jaxb-runtime:jar:2.3.1:compile
[←[1;34mINFO←[m] |     +- org.glassfish.jaxb:txw2:jar:2.3.1:compile
[←[1;34mINFO←[m] |     +- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
[←[1;34mINFO←[m] |     +- org.jvnet.staxex:stax-ex:jar:1.8:compile
[←[1;34mINFO←[m] |     - com.sun.xml.fastinfoset:FastInfoset:jar:1.2.15:compile
[←[1;34mINFO←[m] +- org.hibernate.validator:hibernate-validator:jar:6.0.13.Final:runtime
[←[1;34mINFO←[m] +- org.hibernate.validator:hibernate-validator-cdi:jar:6.0.13.Final:compile
[←[1;34mINFO←[m] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.2.Final:compile
[←[1;34mINFO←[m] +- org.jboss.weld.servlet:weld-servlet-core:jar:3.1.9.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.weld.environment:weld-environment-common:jar:3.1.9.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.weld:weld-spi:jar:3.1.SP4:compile
[←[1;34mINFO←[m] |  +- org.jboss.weld.probe:weld-probe-core:jar:3.1.9.Final:compile
[←[1;34mINFO←[m] |  |  - jakarta.enterprise:jakarta.enterprise.cdi-api:jar:2.0.2:compile
[←[1;34mINFO←[m] |  |     - jakarta.inject:jakarta.inject-api:jar:1.0:compile
[←[1;34mINFO←[m] |  +- org.jboss.weld.module:weld-jsf:jar:3.1.9.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.weld.module:weld-web:jar:3.1.9.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.spec.javax.el:jboss-el-api_3.0_spec:jar:2.0.0.Final:compile
[←[1;34mINFO←[m] |  - org.jboss.classfilewriter:jboss-classfilewriter:jar:1.2.5.Final:compile
[←[1;34mINFO←[m] +- org.jboss.weld:weld-core-impl:jar:3.1.9.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.weld:weld-api:jar:3.1.SP4:compile
[←[1;34mINFO←[m] |  +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec:jar:2.0.1.Final:compile
[←[1;34mINFO←[m] |  - org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:jar:2.0.0.Final:compile
[←[1;34mINFO←[m] +- javax.enterprise:cdi-api:jar:2.0.SP1:provided
[←[1;34mINFO←[m] |  +- javax.interceptor:javax.interceptor-api:jar:1.2:provided
[←[1;34mINFO←[m] |  - javax.inject:javax.inject:jar:1:provided
[←[1;34mINFO←[m] +- javax.servlet:jstl:jar:1.2:compile
[←[1;34mINFO←[m] +- org.jboss:jandex:jar:2.0.5.Final:compile
[←[1;34mINFO←[m] +- com.microsoft.sqlserver:sqljdbc4:jar:4.0:compile
[←[1;34mINFO←[m] +- com.ibm.db2.jdbc:db2jcc4:jar:4.23.42:provided
[←[1;34mINFO←[m] +- com.ibm.db2.jdbc:db2jcc-license-cu:jar:1.0.0:provided
[←[1;34mINFO←[m] +- org.jboss.resteasy:resteasy-servlet-initializer:jar:3.15.3.Final:compile
[←[1;34mINFO←[m] |  +- org.jboss.resteasy:resteasy-jaxrs:jar:3.15.3.Final:compile
[←[1;34mINFO←[m] |  |  +- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar:2.0.1.Final:compile
[←[1;34mINFO←[m] |  |  +- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[←[1;34mINFO←[m] |  |  +- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[←[1;34mINFO←[m] |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[←[1;34mINFO←[m] |  |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[←[1;34mINFO←[m] |  |  |  +- commons-logging:commons-logging:jar:1.2:compile
[←[1;34mINFO←[m] |  |  |  - commons-codec:commons-codec:jar:1.11:compile
[←[1;34mINFO←[m] |  |  +- commons-io:commons-io:jar:2.5:compile
[←[1;34mINFO←[m] |  |  - com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[←[1;34mINFO←[m] |  - org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.1.Final:compile
[←[1;34mINFO←[m] +- org.jboss.resteasy:resteasy-cdi:jar:3.15.3.Final:compile
[←[1;34mINFO←[m] |  - jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[←[1;34mINFO←[m] +- org.jboss.resteasy:resteasy-jackson2-provider:jar:3.15.3.Final:compile
[←[1;34mINFO←[m] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.11.3:compile
[←[1;34mINFO←[m] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.3:compile
[←[1;34mINFO←[m] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.3:compile
[←[1;34mINFO←[m] |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.11.3:compile
[←[1;34mINFO←[m] |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.11.3:compile
[←[1;34mINFO←[m] |  |  - com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.11.3:compile
[←[1;34mINFO←[m] |  |     - jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[←[1;34mINFO←[m] |  +- com.github.fge:json-patch:jar:1.9:compile
[←[1;34mINFO←[m] |  |  - com.github.fge:jackson-coreutils:jar:1.6:compile
[←[1;34mINFO←[m] |  |     - com.github.fge:msg-simple:jar:1.1:compile
[←[1;34mINFO←[m] |  |        - com.github.fge:btf:jar:1.2:compile
[←[1;34mINFO←[m] |  - com.google.guava:guava:jar:28.1-jre:compile
[←[1;34mINFO←[m] |     +- com.google.guava:failureaccess:jar:1.0.1:compile
[←[1;34mINFO←[m] |     +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[←[1;34mINFO←[m] |     - org.checkerframework:checker-qual:jar:2.8.1:compile
[←[1;34mINFO←[m] +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.3:compile
[←[1;34mINFO←[m] +- io.swagger.core.v3:swagger-jaxrs2:jar:2.1.6:compile
[←[1;34mINFO←[m] |  +- io.github.classgraph:classgraph:jar:4.8.65:compile
[←[1;34mINFO←[m] |  +- io.swagger.core.v3:swagger-models:jar:2.1.6:compile
[←[1;34mINFO←[m] |  +- io.swagger.core.v3:swagger-annotations:jar:2.1.6:compile
[←[1;34mINFO←[m] |  - io.swagger.core.v3:swagger-integration:jar:2.1.6:compile
[←[1;34mINFO←[m] |     - io.swagger.core.v3:swagger-core:jar:2.1.6:compile
[←[1;34mINFO←[m] |        +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[←[1;34mINFO←[m] |        - com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.11.1:compile
[←[1;34mINFO←[m] |           - org.yaml:snakeyaml:jar:1.26:compile
[←[1;34mINFO←[m] +- io.swagger.core.v3:swagger-jaxrs2-servlet-initializer-v2:jar:2.1.6:compile
[←[1;34mINFO←[m] +- org.apache.commons:commons-lang3:jar:3.8.1:compile
[←[1;34mINFO←[m] +- org.apache.commons:commons-email:jar:1.5:compile
[←[1;34mINFO←[m] |  - com.sun.mail:javax.mail:jar:1.5.6:compile
[←[1;34mINFO←[m] |     - javax.activation:activation:jar:1.1:compile
[←[1;34mINFO←[m] +- ch.qos.logback:logback-classic:jar:1.3.0-alpha16:compile
[←[1;34mINFO←[m] |  +- ch.qos.logback:logback-core:jar:1.3.0-alpha16:compile
[←[1;34mINFO←[m] |  - org.slf4j:slf4j-api:jar:2.0.0-alpha7:compile
[←[1;34mINFO←[m] +- org.projectlombok:lombok:jar:1.18.4:provided
[←[1;34mINFO←[m] +- de.XXXXX.inhouse:primefaces-XXXXX:jar:1.0.6:compile
[←[1;34mINFO←[m] +- org.webjars:font-awesome:jar:4.7.0:compile
[←[1;34mINFO←[m] +- org.junit.jupiter:junit-jupiter-api:jar:5.5.2:test
[←[1;34mINFO←[m] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[←[1;34mINFO←[m] |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[←[1;34mINFO←[m] |  - org.junit.platform:junit-platform-commons:jar:1.5.2:test
[←[1;34mINFO←[m] +- org.junit.jupiter:junit-jupiter-engine:jar:5.5.2:test
[←[1;34mINFO←[m] |  - org.junit.platform:junit-platform-engine:jar:1.5.2:test
[←[1;34mINFO←[m] +- org.junit.jupiter:junit-jupiter-params:jar:5.5.2:test
[←[1;34mINFO←[m] +- org.junit.vintage:junit-vintage-engine:jar:5.5.2:test
[←[1;34mINFO←[m] |  - junit:junit:jar:4.12:test
[←[1;34mINFO←[m] |     - org.hamcrest:hamcrest-core:jar:1.3:test
[←[1;34mINFO←[m] +- org.mockito:mockito-core:jar:3.2.4:test
[←[1;34mINFO←[m] |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.5:test
[←[1;34mINFO←[m] |  - org.objenesis:objenesis:jar:2.6:test
[←[1;34mINFO←[m] +- org.mockito:mockito-junit-jupiter:jar:3.2.4:test
[←[1;34mINFO←[m] +- org.hamcrest:hamcrest:jar:2.2:test
[←[1;34mINFO←[m] +- org.jglue.cdi-unit:cdi-unit:jar:4.1.0:test
[←[1;34mINFO←[m] |  - org.apache.deltaspike.core:deltaspike-core-impl:jar:1.0.1:test
[←[1;34mINFO←[m] |     - org.apache.deltaspike.core:deltaspike-core-api:jar:1.0.1:test
[←[1;34mINFO←[m] +- org.jboss.weld:weld-junit5:jar:2.0.1.Final:test
[←[1;34mINFO←[m] |  +- org.jboss.weld.se:weld-se-core:jar:3.1.2.Final:test
[←[1;34mINFO←[m] |  - org.jboss.weld:weld-junit-common:jar:2.0.1.Final:test
[←[1;34mINFO←[m] - net.bytebuddy:byte-buddy:jar:1.10.17:compile

web.xml

<resource-env-ref>
    <resource-env-ref-name>BeanManager</resource-env-ref-name>
    <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref> 

<listener>
    <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<listener>
    <listener-class>org.jboss.weld.module.web.servlet.WeldTerminalListener</listener-class>
</listener>

context.xml

<Resource name="BeanManager" auth="Container"
        type="javax.enterprise.inject.spi.BeanManager" 
        factory="org.jboss.weld.resources.ManagerObjectFactory" />

Rest gets pulled up with class “DefaultJaxRsApplication.java”:

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("api/v1")
public class DefaultJaxRsApplication extends Application {
    // Empty
}

Swagger Backend gets pulled up with class “CustomOpenApiServlet.java”:

import javax.servlet.annotation.WebServlet;
import io.swagger.v3.jaxrs2.integration.OpenApiServlet;

@WebServlet(value = "/openapi/*", name = "OpenApiServlet")
public class CustomOpenApiServlet extends OpenApiServlet {
    private static final long serialVersionUID = -8507389627665542354L;
}

Swagger Backend has a WebFilter “OpenApiFilter.java”:

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

@WebFilter(servletNames = "OpenApiServlet")
public class OpenApiFilter implements Filter {

    @Override
    public void doFilter(
        final ServletRequest servletRequest,
        final ServletResponse servletResponse,
        final FilterChain filterChain) throws IOException, ServletException {

        servletResponse.setContentType(APPLICATION_JSON);
        servletResponse.setCharacterEncoding("UTF-8");

        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {
        // No Objects to destroy
    }

    @Override
    public void init(FilterConfig arg0) throws ServletException {
        // Nothing to init
    }

}

Swagger UI has a config “openapi.yaml” in WEB-INF Folder:

prettyPrint: true
modelConverterClasses: [ 'de.XXXXX.intern.XXXXX.rest.swagger.CustomPropertyConverter' ]
openAPI:
    info:
        title: XXXXX
        version: API-v1
servers:
    - url: /APP-CONTEXT/api/v1
      description: Aktueller Server

Additional: maybe there is a problem with a memory leak with hot-deploying this app on Tomcat. Local I have no problems, but on acceptance environment server, clicking the button “Find leaks” in the tomcat manager app shows:

The following web application were stopped (reloaded, undeployed), but their classes from previous runs are still loaded in memory, thus causing a memory leak

Leave a Comment