I try to setup CDI/Weld and JAX-RS/RESTEasy on Netty in a Java SE environment, but all I get is the following exception:
javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8000/
My project has the following dependencies:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty4</artifactId>
<version>3.0.5.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-cdi</artifactId>
<version>3.0.5.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.12.Final</version>
</dependency>
I placed a beans.xml file in the src/main/resources/META-INF directory to enable CDI.
The code to start netty:
@Singleton
public class App {
private static NettyJaxrsServer netty;
public void printHello(
@Observes ContainerInitialized event,
@Parameters List<String> parameters)
throws Exception {
System.out.println("Starting Netty ...");
ResteasyDeployment deployment = new ResteasyDeployment();
netty = new NettyJaxrsServer();
netty.setDeployment(deployment);
netty.setPort(8000);
netty.setRootResourcePath("");
netty.setSecurityDomain(null);
netty.start();
}
The example resource looks like this:
@Path("/hi") // tried "/" too
public class Index {
@GET
public String get() {
return "Hi!";
}
}
Since all of this didn't work, I added an application class:
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/")
public class DemoApplication extends Application {
// empty
}
But the error message is still the same.
What is missing? How can I setup Weld and RESTEasy?