JAX-RS 2.0 supports stateless and singleton session beans as root resource classes. In this section, we will run the AsyncResource
root resource class as a stateless session bean. We added an EJB-related dependency to pom.xml
.
Annotate the AsyncResource
with the Stateless
annotation. The @Path
annotation must also be applied to the class:
@Path("/helloworld") @Stateless public class AsyncResource {}
When the application is run, the root resource class gets added to the JNDI just as any other session bean would. The JNDI binding for AsycnResource
is shown as follows: