I have a rest service implemented as follows
@Stateless
@Path("/Person")
@Produces(MediaType.APPLICATION_XML)
public class RestService {
@PersistenceContext(unitName = "mysqlPU")
EntityManager em;
@GET
@Path("{id}")
public Response Book(@PathParam("id") Long id) {
Person person = em.find(Person.class, id);
if(person == null) {
return Response.status(Response.Status.FORBIDDEN).build();
}
return Response.ok(person).build();
}
}
@ApplicationPath("/rs")
public class ApplicationConfig extends Application {
private final Set<Class<?>> classes;
public ApplicationConfig() {
HashSet<Class<?>> c = new HashSet<Class<?>>();
c.add(RestService.class);
classes = Collections.unmodifiableSet(c);
}
@Override
public Set<Class<?>> getClasses() {
return classes;
}
}
It is packaged in a jar file with other ejbs, outside of any .war. I'm am only able to access the service if I happen to have a war package inside the ear. I can access it with the context root of the war such as localhost:8080/warContextRoot/rs/. Is there any way to deploy a rest service without also deploying a war and still access it?