@Path Annotation requirements?

I’m new to specifying resource routes in Java, and I’m having issues specifying the route. So far I have one Class which simply extends Application, and one class that reacts to input. What are the routing requirements for these classes? My code below does not work and im trying to figure out why. I’ve tried to find sources for these, but haven’t had much luck.

  1. Can I just use a / for the ApplicationPath? All this class does is extend Application so it can find routes.


package com.sentiment360.helloworld;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

 * JAXActivator is an arbitrary name, what is important is that javax.ws.rs.core.Application is extended
 * and the @ApplicationPath annotation is used with a "rest" path.  Without this the rest routes linked to
 * from index.html would not be found.
public class JAXActivator extends Application {

Does each class need to have a declared @Path (or can they all be @Stateless)?

public class HelloService {

    private static Logger _logger;

    public HelloService(){
        _logger = Logger.getLogger(HelloService.class.getName());

    private Connection conn() throws SQLException  {...}

The short version for #1 is yes.

BUT: behavior is implementation dependent. See https://stackoverflow.com/a/16747253/1063501 for a thorough explanation.

As for #2, yes, you generally need to specify a @Path for every endpoint you want. The fact that it is @Stateless is irrelevant as you’ll need a way to address it.