Do I need a JAX-RS military module?

Is a JAX-RS web module required WARor am I doing something wrong?

Each tutorial shows how to set up rest's service web.xml. But there is no ejb module web.xml. Should I create WARjust for the leisure service?

In my ejb module, I want to open EJB as a recreation service, but I cannot get it to work. Calling "localhost: 8080 / EjbModule / rest / test / method" results in 404

Project structure

- ear
    - EjbModule.jar

the code

Providing Bean as a JAX-WS web service and testing it in a browser is not a problem.

@ApplicationPath("rest")
public class RestApplication extends Application
{
    @Override
    public Set<Class<?>> getClasses()
    {
        final Set<Class<?>> classes = new HashSet<>(1);
        classes.add(TestService.class);
        return classes;
    }
}


@Stateless
@Path("/test")
public class TestService
{
    @Path("/method")
    @GET
    @Produces(MediaType.TEXT_HTML)
    public String test()
    {
        return new Date().toString();
    }
}

Environment: Glassfish 4.0

Edit:

Creating a separate WARbreakpoint service works as expected.

+4
source share
1

JAX-RS 2.0 . 8:

2.3.2 Servlet

JAX-RS - .war. WEB-INF/ WEB-INF/lib WEB-INF/lib. Servlet - .

, JAX-RS -. , , ejb Java SE. :

JAX-RS , .

+4

Source: https://habr.com/ru/post/1544412/


All Articles