thorntail / thorntail-generator

Thorntail Generator Server-side
http://wildfly-swarm.io/generator
3 stars 6 forks source link

Generated a non-functioning JAX-RS project #4

Closed EricWittmann closed 6 years ago

EricWittmann commented 6 years ago

I generated a project with the following fractions:

CDI, JAX-RS, DataSources, MP+OpenAPI

The resulting project had a HelloWorldEndpoint JAX-RS class like this:

@ApplicationScoped
@Path("/hello")
public class HelloWorldEndpoint {

    @GET
    @Produces("text/plain")
    public Response doGet() {
        return Response.ok("Hello from WildFly Swarm!").build();
    }
}

However there was no web.xml defined (fine) and no JAX-RS application class defined (not fine).

In order to properly start, there should be either a web.xml with a resteasy servlet defined or a JAX-RS application class defined. Like this:


import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationScoped
@ApplicationPath("/")
public class HelloWorldApplication extends Application {
}

Clearly the latter option is better. :)

jclingan commented 6 years ago

I just ran into this issue as well as I'm updating my Java Microservices course. The generator should also generate an Application class (preferred).

kenfinnigan commented 6 years ago

Resolved as part of #5