Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTEASY-2552 create sample-app for wildfly deployment #72

Merged
merged 8 commits into from Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -13,6 +13,7 @@
<modules>
<module>resteasy-spring-boot-starter</module>
<module>sample-app</module>
<module>sample-app-for-wildfly</module>
<module>sample-app-no-jaxrs-application</module>
<module>resteasy-spring-boot-starter-test</module>
</modules>
Expand Down
55 changes: 55 additions & 0 deletions sample-app-for-wildfly/README.md
@@ -0,0 +1,55 @@
# Sample application for Wildfly Deployment

This example is for deploying to Wildfly Java EE Full & Web Distribution.

First you should package this sample:

```bash
$ mvn package
```

And it will generate the WAR file:

```txt
works/resteasy-spring-boot/sample-app-for-wildfly/target/sample-app.war
```

Then start the Wildfly server:

```bash
$ ./standalone.sh
...
15:01:50,343 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 19.0.0.Final (WildFly Core 11.0.0.Final) started in 3332ms - Started 316 of 582 services (374 services are lazy, passive or on-demand)
```

After the server started, use the `jboss-cli.sh` to connect to the server:

```bash
$ ./jboss-cli.sh
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 /]
```

In the command line console, use the `deploy` command to deploy this sample's WAR file:

```bash
[standalone@localhost:9990 /] deploy works/resteasy-spring-boot/sample-app-for-wildfly/target/sample-app.war --force
```

From server side we can see it's deployed:

```bash
16:30:42,046 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 449) WFLYUT0021: Registered web context: '/sample-app' for server 'default-server'
```

## Testing it

Here is the command to access the server:

```bash
$ curl localhost:8080/sample-app/rest/hello
Hello, world!
```

From above we can see the `HelloResource` served the request and output response generated from `EchoBean`, which is a spring bean wired into `HelloResource`.
106 changes: 106 additions & 0 deletions sample-app-for-wildfly/pom.xml
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>org.jboss.resteasy</groupId>
<artifactId>spring-boot-sample-app-for-wildfly</artifactId>
<version>4.6.0.Final-SNAPSHOT</version>
<packaging>war</packaging>

<description>Simple test application for the Resteasy Spring Boot starter to deploy to Wildfly</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<resteasy.version>4.5.1.Final</resteasy.version>
<springboot.version>2.2.2.RELEASE</springboot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- we need to remove tomcat from WAR becasue this project will be deployed to Wildfly-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>sample-app</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>

<!--
The configuration below was added to enable integration tests
and is not usually necessary for real Spring Boot applications
-->
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>

</project>
10 changes: 10 additions & 0 deletions sample-app-for-wildfly/src/main/java/com/sample/app/EchoBean.java
@@ -0,0 +1,10 @@
package com.sample.app;

import org.springframework.stereotype.Component;

@Component
public class EchoBean {
public String echo(String val) {
return val;
}
}
@@ -0,0 +1,20 @@
package com.sample.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Component
@Path("/hello")
public class HelloResource {

@Autowired
EchoBean bean;

@GET
public String get() {
return bean.echo("Hello, world!");
}
}
@@ -0,0 +1,8 @@
package com.sample.app;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class RestApp extends Application {
}
20 changes: 20 additions & 0 deletions sample-app-for-wildfly/src/main/java/com/sample/app/SpringApp.java
@@ -0,0 +1,20 @@
package com.sample.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;


/**
* SpringBoot entry point application
*
* To deploy to Wildfly, this class must extends SpringBootServletInitializer.
*/
@SpringBootApplication
public class SpringApp extends SpringBootServletInitializer {

public static void main(String[] args) {
SpringApplication.run(SpringApp.class, args);
}

}
5 changes: 5 additions & 0 deletions sample-app-for-wildfly/src/main/resources/application.yaml
@@ -0,0 +1,5 @@
resteasy:
jaxrs:
app:
registration: property
classes: com.sample.app.RestApp
@@ -0,0 +1,7 @@
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs"/>
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
1 change: 1 addition & 0 deletions sample-app/pom.xml
Expand Up @@ -17,6 +17,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<resteasy.version>4.5.1.Final</resteasy.version>
<springboot.version>2.2.2.RELEASE</springboot.version>

</properties>

<dependencyManagement>
Expand Down
@@ -1,4 +1,4 @@
package com.sample.app.enpoint.echo;
package com.sample.app.resource.echo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down
@@ -1,4 +1,4 @@
package com.sample.app.enpoint.echo;
package com.sample.app.resource.echo;

/**
* A simple echo message, containing the text to be echoed
Expand Down
@@ -1,4 +1,4 @@
package com.sample.app.enpoint.echo;
package com.sample.app.resource.echo;

import org.springframework.stereotype.Component;

Expand Down