Java Reference
In-Depth Information
Listing 8.9. JSON Bid DTO encoding
If you attempt to run this code, the JAX-RS implementation will most likely complain
that it doesn't know how to instantiate BidServiceRS , which is an interface. To asso-
ciate the stateless session bean with the service, you'll need to implement a
.rs.core.Application and return instances for all JAX-RS annotated interfaces.
The Application instance, shown in the next listing, is then registered with the JAX-RS
servlet in web.xml (not shown). This will work for the reference implementation Metro,
but other JAX-RS implementations may have different mechanisms.
Listing 8.10. Configuring JAX-RS interface instances
public class SystemInit extends Application {
public Set<Class<?>> getClasses() {
return Collections.emptySet();
public Set<Object> getSingletons() {
Set<Object> classes = new HashSet<Object>();
try {
InitialContext ctx = new InitialContext();
Object bidServiceRS =
} catch (Throwable t) {
return classes;
Now that you've seen a basic example of a JAX-RS service, let's review the annotations in
more depth.
Search WWH ::

Custom Search