javamavenwildflyresteasyjava-ee-8

RESTful Endpoints Not Found on Wildfly


I am trying to configure RESTful endpoints on an existing Wildfly Java project that to this point has been running as a Kafka consumer / producer.

My experience has previous been using Thorntail, but either way, I've always used RESTEasy's JAX-RS jars for endpoint annotations.

I've set up the code as follows:

ApiDeclaration

ApplicationPath("/api")
public class ApiDeclaration extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> set = new HashSet<Class<?>>();
//        set.add(CorsFilter.class);
        set.add(ClaimApiImpl.class);
        return set;
    }
}

ClaimApi

@Path("/claim")
public interface ClaimApi {
    @POST
    @Path("/process")
    @Produces({MediaType.APPLICATION_XML})
    @Consumes({MediaType.APPLICATION_XML})
    Response processClaim(ClaimRequest claimRequest);

    @POST
    @Path("/reverse")
    @Produces({MediaType.APPLICATION_XML})
    @Consumes({MediaType.APPLICATION_XML})
    Response reverseClaim(ClaimReversal claimReversalRequest);
}

ClaimApiImpl

@ApplicationScoped
public class ClaimApiImpl implements ClaimApi {

    @Override
    public Response processClaim(ClaimRequest claimRequest) {

        try {
            return Response
                    .status(Response.Status.OK)
                    .entity("Working!")
                    .build();
        } catch (Exception ex) {
            return Response
                    .status(Response.Status.INTERNAL_SERVER_ERROR)
                    .entity(("Error!"))
                    .build();
        }
    }
}

The POM.xml is set up as follows (it's a bit of a mess at the moment):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.greydom.integration</groupId>
    <artifactId>integration-layer</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- This needs to stay at 8 until wildfly/jakarta upgraded again -->
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <!-- PLATFORM -->
        <version.jakarta.jakartaee-api>8.0.0</version.jakarta.jakartaee-api>
        <version.wildfly>26.1.2.Final</version.wildfly>
        <version.opentracing-api>0.31.0</version.opentracing-api>
        <version.wildfly-jar-maven-plugin>8.0.0.Final</version.wildfly-jar-maven-plugin>
        <version.wildfly-datasources-galleon-pack>2.2.2.Final</version.wildfly-datasources-galleon-pack>
        <version.keycloak-adapter-galleon-pack>13.0.1</version.keycloak-adapter-galleon-pack>

        <version.maven-war-plugin>3.3.2</version.maven-war-plugin>
        <version.maven-assembly-plugin>3.2.0</version.maven-assembly-plugin>
        <version.maven-deploy-plugin>2.8.2</version.maven-deploy-plugin>
        <!-- CAMEL -->
        <version.camel>3.19.0</version.camel>
        <!-- JWT -->
        <version.jwt>0.7.0</version.jwt>
        <version.java-jwt>3.4.0</version.java-jwt>
        <!-- ECLIPSELINK -->
        <version.eclipselink>2.7.1</version.eclipselink>

        <!-- POSTGRESQL CLIENT -->
        <version.postgresql>42.2.1</version.postgresql>
        <version.ironjacamar-jdbc>1.4.38.Final</version.ironjacamar-jdbc>
        <!-- PRIMEFACES - maybe ?? -->
        <!-- LOGGING -->
        <version.log4j-core>2.11.0</version.log4j-core>
        <version.infinispan>9.4.19.Final</version.infinispan>
        <!-- COMMONS LIBS -->
        <version.commons-lang>2.6</version.commons-lang>
        <version.commons-io>1.4</version.commons-io>
        <version.commons-csv>1.9.0</version.commons-csv>
        <version.commons-codec>1.9</version.commons-codec>
        <version.beanutils>1.9.2</version.beanutils>
        <version.commons-lang3>3.12.0</version.commons-lang3>
        <version.commons-collections4>4.1</version.commons-collections4>
        <version.commons-csv>1.9.0</version.commons-csv>
        <version.lombok>1.18.12</version.lombok>

        <version.java-uuid-generator>4.0.1</version.java-uuid-generator>
        <version.jaxb-impl>2.3.4</version.jaxb-impl>

        <version.git-commit-id-plugin>2.2.4</version.git-commit-id-plugin>
        <version.maven-compiler-plugin>3.10.1</version.maven-compiler-plugin>
        <version.maven-failsafe-plugin>2.22.2</version.maven-failsafe-plugin>

        <!-- TESTING -->
        <version.org.wildfly.arquillian>3.0.0.Final</version.org.wildfly.arquillian>
        <version.org.jboss.arquillian.junit>1.6.0.Final</version.org.jboss.arquillian.junit>
        <version.junit>4.13.1</version.junit>
        <version.org.jboss.shrinkwrap.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap.shrinkwrap>
        <version.org.jboss.shrinkwrap.resolver>3.1.4</version.org.jboss.shrinkwrap.resolver>

        <!-- LOMBOK -->
        <lombok.version>1.18.12</lombok.version>

        <!-- GSON -->
        <gson.version>2.12.2</gson.version>

        <!-- INFINISPAN -->
        <version.infinispan>9.4.19.Final</version.infinispan>

        <resteasy.version>3.0.14.Final</resteasy.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-jakartaee8-with-tools</artifactId>
                <version>${version.wildfly}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-microprofile</artifactId>
                <version>${version.wildfly}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-bom</artifactId>
                <version>${version.camel}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- PLATFORM START -->
        <dependency>
            <groupId>org.jboss.ironjacamar</groupId>
            <artifactId>ironjacamar-jdbc</artifactId>
            <version>${version.ironjacamar-jdbc}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>${version.jakarta.jakartaee-api}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.health</groupId>
            <artifactId>microprofile-health-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.config</groupId>
            <artifactId>microprofile-config-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.metrics</groupId>
            <artifactId>microprofile-metrics-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.fault-tolerance</groupId>
            <artifactId>microprofile-fault-tolerance-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.opentracing</groupId>
            <artifactId>microprofile-opentracing-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.opentracing</groupId>
            <artifactId>opentracing-api</artifactId>
            <version>${version.opentracing-api}</version>
        </dependency>

        <!-- CAMEL -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-servlet</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-swagger-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xj</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jaxb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xpath</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-mapstruct</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cdi</artifactId>
        </dependency>
        <!--        <dependency>-->
        <!--            <groupId>org.apache.camel</groupId>-->
        <!--            <artifactId>camel-file</artifactId>-->
        <!--        </dependency>-->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-log</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-master</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-zookeeper-master</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-endpointdsl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-componentdsl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jsonpath</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>${version.jaxb-impl}</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.1-jre</version>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>${version.beanutils}</version>
        </dependency>

        <!-- LOGGING -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.14.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.14.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.30</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.6</version>
        </dependency>

        <dependency>
            <groupId>com.monitorjbl</groupId>
            <artifactId>xlsx-streamer</artifactId>
            <version>2.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-csv</artifactId>
            <version>${version.commons-csv}</version>
        </dependency>

        <!-- KEYCLOAK ADMIN CLIENT -->
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-admin-client</artifactId>
            <version>13.0.1</version>
        </dependency>

        <!-- POSTGRESQL CLIENT -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${version.postgresql}</version>
        </dependency>

        <!-- ECLIPSELINK -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>${version.eclipselink}</version>
        </dependency>

        <!-- INFINISPAN CACHE -->
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>${version.infinispan}</version>
        </dependency>

        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-commons</artifactId>
            <version>${version.infinispan}</version>
        </dependency>

        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-query</artifactId>
            <version>${version.infinispan}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.infinispan</groupId>
                    <artifactId>infinispan-directory-provider</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-directory-provider</artifactId>
            <version>${version.infinispan}</version>
        </dependency>

        <!-- TESTING -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-test-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.stefanbirkner</groupId>
            <artifactId>fake-sftp-server-lambda</artifactId>
            <version>2.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-netty-no-dependencies</artifactId>
            <version>5.14.0</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.descriptors</groupId>
            <artifactId>shrinkwrap-descriptors-depchain</artifactId>
            <type>pom</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
            <version>1.0.0.Final</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core</artifactId>
            <version>2.2.15.Final</version>
            <scope>test</scope>
        </dependency>

        <!-- LOMBOK -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- GSON -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>${gson.version}</version>
        </dependency>

    </dependencies>


    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-jar-maven-plugin</artifactId>
                <version>${version.wildfly-jar-maven-plugin}</version>
                <configuration>
                    <cli-sessions>
                        <cli-session>
                            <script-files>
                                <script>build_scripts/cli/integration-layer_config.cli</script>
                            </script-files>
                            <properties-file>build_scripts/integration-layer_config.properties</properties-file>
                        </cli-session>
                    </cli-sessions>
                    <extra-server-content-dirs>
                        <extra-content>build_scripts/extra_content</extra-content>
                    </extra-server-content-dirs>
                    <feature-packs>
                        <feature-pack>
                            <location>wildfly@maven(org.jboss.universe:community-universe)#${version.wildfly}</location>
                        </feature-pack>
                        <feature-pack>
                            <groupId>org.wildfly</groupId>
                            <artifactId>wildfly-datasources-galleon-pack</artifactId>
                            <version>${version.wildfly-datasources-galleon-pack}</version>
                        </feature-pack>            
                    </feature-packs>
                    <layers>
                        <layer>microprofile-platform</layer>
                        <layer>jaxrs</layer>
                        <layer>postgresql-driver</layer>
                        <layer>jpa</layer>
                        <layer>cdi</layer>
                        <layer>logging</layer>
                    </layers>
                    <excluded-layers>
                        <layer>deployment-scanner</layer>
                    </excluded-layers>
                    <plugin-options>
                        <jboss-fork-embedded>${plugin.fork.embedded}</jboss-fork-embedded>
                    </plugin-options>
                    <context-root>false</context-root>
                    <hollow-jar>true</hollow-jar>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${version.maven-war-plugin}</version>
                <configuration>
                    <warName>${project.artifactId}</warName>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.maven-compiler-plugin}</version>
                <configuration>
                    <!-- Original answer -->
                    <compilerArgument>-parameters</compilerArgument>
                    <!-- Or, if you use the plugin version >= 3.6.2 -->
                    <!--                    <parameters>true</parameters>-->
                    <!--                    <testCompilerArgument>-parameters</testCompilerArgument>-->
                    <!--                    <source>${java.version}</source>-->
                    <!--                    <target>${java.version}</target>-->
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>1.5.3.Final</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${version.lombok}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${version.maven-failsafe-plugin}</version>
                <executions>
                    <execution>
                        <id>jaxrs.surefire</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <failIfNoTests>false</failIfNoTests>
                            <systemPropertyVariables>
                                <bootable.jar>${project.build.directory}/api-bootable.jar</bootable.jar>
                                <arquillian.xml>arquillian.xml</arquillian.xml>
                            </systemPropertyVariables>
                            <redirectTestOutputToFile>false</redirectTestOutputToFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>

Is there anything extra that specifically needs to be added to get endpoints exposed?

I’ve set the port to listen on 8089, and I can see this is working from the following startup log:

The above code should expose an endpoint on http://localhost:8089/api/claim/process, but I get a 404 not found.

I am concerned there are issues in teh POM.xml file, but I am no longer sure what to try, hence the question.

FYI, I have refrred to these questions too:


Solution

  • The fix was to add the following exclusions to Keycloak:

           <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-admin-client</artifactId>
                <version>13.0.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-client</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-multipart-provider</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-jaxb-provider</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>