I am trying to figure out what is my problem while setting up new Wildfly 8.2 server with simple restEasy 3.0.10 application.
my web application is supre easy.
src/main/
java/my-package/
RootApplication.java
HomePageResource.java
webapp/
index.html
WEB-INF/
beans.xml
web.xml
web.xml and beans.xml look like this
---- web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
metadata-complete="false">
</web-app>
---- beans.xml
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
in RootApplication.java I have
@ApplicationPath("/app")
public class RootApplication extends Application
{
private Set<Object> singletons = new HashSet<>();
public RootApplication()
{
singletons.add(new HomePageResource());
}
@Override
public Set<Object> getSingletons()
{
return singletons;
}
}
// ResourceProvider is a simple class hiding getResource and createStreamer
@Path("/")
public class HomePageResource extends ResourceProvider
{
private final static Logger logger = LoggerFactory.getLogger(HomePageResource.class);
@GET
@Produces(MediaType.TEXT_HTML)
public Response getHomePage()
{
final InputStream homePageResource = getResource("/static/view/home/home.html");
return Response.ok(createStreamer(homePageResource)).build();
}
}
which works but I have never specified any resource classes inside Application and RestEasy was always able to scan WAR content. And if I remove everything from RootApplication, like this.
@ApplicationPath("/app")
public class RootApplication extends Application
{
}
Anyway documentation also says (https://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html_single/)
Since we're not using a jax-rs servlet mapping, we must define an Application class that is annotated with the @ApplicationPath annotation. If you return any empty set for by classes and singletons, your WAR will be scanned for JAX-RS annotation resource and provider classes.
any hints what I may do wrong with this simple setup??? and another question can I remove beans.xml to use guice DI, I understand this problem has nothing to do with CDI/WELD.
my pom.xml looks like this
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-bom</artifactId>
<version>3.0.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
</dependency>
</dependencies>