RESTEasy WADL module deployment on Wildfly

By Wei Nan | January 18, 2021

There was request to include RESTEasy WADL module into WildFly by default. While the issue is under discussion, we can have an example showing how to deploy the RESTEasy WADL module by yourself into WildFly.

To achieve the goal, firstly we need to add the resteasy-wadl as the dependency of the project we want to deploy to WildFly. And if the project is using Maven, here is the configuration need be put into pom.xml:

<dependency>
   <groupId>org.jboss.resteasy</groupId>
   <artifactId>resteasy-wadl</artifactId>
   <version>${resteasy.ver}</version>
</dependency>

In above config, the ${resteasy.ver} is the RESTEasy version you used in your project. Because WildFly has its own RESTEasy module, so I recommend that the project to use the same RESTEasy version used by your WildFly server.

To check the RESTEasy version used by your WildFly, you can check your WildFly’s module directory like this:

$ ls modules/system/layers/base/org/jboss/resteasy/resteasy-jaxrs/main/
module.xml
resteasy-client-3.14.0.Final.jar
resteasy-jaxrs-3.14.0.Final.jar
resteasy-tracing-api-1.0.0.Final.jar
$

From the above output, we can see WildFly on my machine is using RESTEasy 3.14.0.Final by default. So 3.14.0.Final is the version of the resteasy-wadl module I would want to use, or I might incur incompatibility issues.

Another possible solution is to upgrade the RESTEasy modules inside WildFly, this way you can use the newest RESTEasy releases, and here is the document describing how to do it:

Please note the above solution may be unsafe, because the RESTEasy version may not be integrated and tested by WildFly team yet.

Above is the WildFly side that needs to be noted. Coming back to the project side, here is the sample code to enable the resteasy-wadl module:

import org.jboss.resteasy.wadl.ResteasyWadlDefaultResource;
import org.jboss.resteasy.wadl.ResteasyWadlWriter;

import javax.ws.rs.Path;

@Path("/")
public class MyWadlResource extends ResteasyWadlDefaultResource {

    public MyWadlResource() {
        ResteasyWadlWriter.ResteasyWadlGrammar wadlGrammar = new ResteasyWadlWriter.ResteasyWadlGrammar();
        wadlGrammar.enableSchemaGeneration();
        getWadlWriter().setWadlGrammar(wadlGrammar);

    }
}

The above sample class will enable the resteasy-wadl module and register its service at root URL ‘/’. In addition, it enables the WADL grammar support.

To see the detail usage and source code of the example, please check the sample here inside the resteasy-examples project:

If you’ve met any problems during its usage, please feel free to submit issue report at:

Enjoy!

         

YourKit
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications. YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor