Deploy RESTEasy-Spring project into WildFly Servlet-Only Container

By Wei Nan Li | April 10, 2020

In this blog I’d like to demonstrate the process to deploy the resteasy-spring-basic example project into WildFly Servlet-Only Distribution.

The example can be fetched from here:

You can clone the example project and do the package of the example by running the Maven command:

$ pwd
resteasy-examples/resteasy-spring-basic
$ mvn package
...
[INFO] BUILD SUCCESS

After packaging is done we can get a WAR file:

$ ls target/*.war
target/resteasy-spring-example-basic.war

We will use this war to deploy to the WildFly server later.

The next step is to download the WildFly, and here is the download link:

In the download page, you can find the Servlet-Only Distribution. And Click the ZIP format to download it.

For the time I’m writing this blog, the 19.0.0.Final is the latest version, so I downloaded the wildfly-servlet-19.0.0.Final.zip from the page.

After the zip is downloaded, I extract it to my work directory:

$ cd wildfly-servlet-19.0.0.Final

And then I entered the bin directory for the server:

$ cd bin

Then I run the WildFly in standalone mode:

$ ./standalone.sh
...
14:49:27,801 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Servlet 19.0.0.Final (WildFly Core 11.0.0.Final) started in 1772ms - Started 138 of 142 services (40 services are lazy, passive or on-demand)

From above we can see the server is started. Then I opened another terminal window and enter the bin directory again:

$ pwd
wildfly-servlet-19.0.0.Final/bin

Then I run the jboss-cli.sh in the directory and use it to connect to the server:

$ ./jboss-cli.sh
connect You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect localhost
[standalone@localhost:9990 /]

As the text shown above it connected to the WildFly server. Then I deployed the WAR file into the server with following command:

[standalone@localhost:9990 /] deploy resteasy-examples/resteasy-spring-basic/target/resteasy-spring-example-basic.war

After running the above command, the server outputs the log:

14:50:34,459 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) WFLYUT0021: Registered web context: '/resteasy-spring-example-basic' for server 'default-server'
14:50:34,496 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "resteasy-spring-example-basic.war" (runtime-name : "resteasy-spring-example-basic.war")

As the log shows the project is deployed. Now we can try to access the service:

$ curl http://localhost:8080/resteasy-spring-example-basic/rest/foo/hello
Hello, world!

As the output shown above we can see the service can be accessed.

         

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