0

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!

L. Monty
  • 872
  • 9
  • 17

1 Answers1

2

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

V G
  • 18,822
  • 6
  • 51
  • 89
  • Thank you. Seems like I missunderstood an article I read. At second option of the answer of Pascal Thivent at http://stackoverflow.com/questions/3027834/inject-a-ejb-into-jax-rs-restfull-service he annotates @Statelessi a JAX-RS resource class. Anyway this does not make it an EJB what i missunderstood. – L. Monty Jan 15 '15 at 11:53