jax-rswildflyresteasy

Adding Resteasy-multipart-provider to my POM breaks previously working REST Services


I need a REST Service to handle File uploads. I added the RESTEasy Multipart Provider dependency:

<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-multipart-provider</artifactId>
    <version>3.1.4.Final</version>
</dependency>

This somehow caused my other REST Services to stop working properly, and they now return errors:

<html>
    <head>
        <title>Error</title>
    </head>
    <body>Not Found</body>
</html>

or

<html>
    <head>
        <title>Error</title>
    </head>
    <body>HTTP method POST is not supported by this URL</body>
</html>

I read that this happens because the implementation of doGet() and doPost() are missing. I don't understand how simply adding this dependency affects my other webservices. Does it add a new Servlet ?

This is my Web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <display-name>my_project</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <filter>
        <filter-name>CORS</filter-name>
        <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>

        <init-param>
            <param-name>cors.allowGenericHttpRequests</param-name>
            <param-value>true</param-value>
        </init-param>

        <init-param>
            <param-name>cors.allowOrigin</param-name>
            <param-value>*</param-value>
        </init-param>

        <init-param>
            <param-name>cors.allowSubdomains</param-name>
            <param-value>false</param-value>
        </init-param>

        <init-param>
            <param-name>cors.supportedMethods</param-name>
            <param-value>GET, HEAD, POST, DELETE, OPTIONS, PUT</param-value>
        </init-param>

        <init-param>
            <param-name>cors.supportedHeaders</param-name>
            <param-value>*</param-value>
        </init-param>

        <init-param>
            <param-name>cors.exposedHeaders</param-name>
            <param-value>Authorization, next-jwt-token</param-value>
        </init-param>

        <init-param>
            <param-name>cors.supportsCredentials</param-name>
            <param-value>true</param-value>
        </init-param>

        <init-param>
            <param-name>cors.maxAge</param-name>
            <param-value>3600</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <!-- CORS Filter mapping -->
        <filter-name>CORS</filter-name>
        <url-pattern>*</url-pattern>
    </filter-mapping>
</web-app>

Solution

  • The version of the dependency was not the one my wildfly was using. I solved my problem by changing the version to the correct one (3.0.24.Final, which ships with WildFly 11 Final), and I changed the scope to provided:

    <!-- Resteasy-multipart-provider -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-multipart-provider</artifactId>
        <version>3.0.24.Final</version>
        <scope>provided</scope>
    </dependency>