CDI JAXRS Bean configured with getSingletons() configuration , @EJB injection is not working in JBoss EAP 7

Solution Verified - Updated -

Issue

CDI JAXRS Bean configured with getSingletons() configuration , @EJB injection is not working in JBoss EAP 7

@ApplicationPath("/jaxrs")
public class RESTApplication extends Application {
    private Set<Object> singletons = new HashSet();
    private Set<Class<?>> empty = new HashSet();

    public RESTApplication() {
        this.singletons.add(new MyRESTService());
    }
    public Set<Class<?>> getClasses() {
        return this.empty;
    }
    public Set<Object> getSingletons() {
        return this.singletons;
    }
}
@RequestScoped
@Path(“/MyApp”)
public class RESTApplication {
   @EJB
   private MyEJBLocal myEJB;

  @GET()
  @Path("/test/{id}")
  @Produces("application/xml")
  public Response test(@PathParam("id") Integer id) throws Exception {
      System.out.println("myEJB: " + myEJB);
  } 
}

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 7.2.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In