Using EJB inside a JAX-RS resource class in RestEasy?

I would like to have the following resource class work when deploying to RestEasy in JBoss 6:

@Path("Something")
public class Foo {

  @EJB
  private SomeService service

  @GET
  public Object frobnicate() {
    assert service != null;
    // JBoss blows up here

    return result;
  }
}

Two questions:

  • This is a RestEasy restriction, not a Java EE specification, is it correct that RestEasy cannot inject anything annotated with @EJB?
  • What have people done to get around this limitation?

My developers are going to move forward with hard-coded JNDI requests (e.g. context.lookup (someHardCodedNameHere)) because no one can find a workaround for this specification violation at this time. I really want to avoid this.

Finally, I looked at using CDI, but the story here is not much better, since RestEasy and CDI still don't talk to each other.

Thanks in advance for any pointers.

+3
1

JBoss , . , 3 JBoss 6 .

+2

Source: https://habr.com/ru/post/1749666/


All Articles