L. Monty
L. Monty

Reputation: 882

JaxRS: REST URL not reachable. Misconfigured?

I try to build up a simple EJB-project on JBoss Wildfly.
I want a stateless EJB to be a JAX-RS resource class. This REST-service should simply return the Person-entities saved in the database.

EJB-Code:

@Stateless
@Path("/person")
public class PersonServiceBean {

    @PersistenceContext EntityManager em;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<Person> getAllPersons(){
        return em.createQuery("FROM " + Person.class.getName()).getResultList();
    }

}

I read I need a subclass of Application with ApplicationPath-annotation

@ApplicationPath("/rest")
public class JaxRsApplication extends Application {

    @Override
    public Set<Class<?>> getClasses() {
        return new HashSet<Class<?>>(Arrays.asList(PersonServiceBean.class));
    }

}

But still I get 404 at 'localhost:8080/rest/person'.
Did I miss to configure something?

I would be really thankful for help!

Upvotes: 0

Views: 307

Answers (1)

V G
V G

Reputation: 19002

The problem is that the Rest Resource must be in a WAR and not in a EJB project.

Upvotes: 2

Related Questions