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

Posted by Laird Nelson on Stack Overflow See other posts from Stack Overflow or by Laird Nelson
Published on 2010-06-11T19:46:02Z Indexed on 2010/06/14 12:52 UTC
Read the original article Hit count: 338

Filed under:
|
|

I would like to have the following kind of resource class work when deployed under 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:

  1. It is a limitation of RestEasy, not of the Java EE specification, right, that RestEasy can't inject anything annotated with @EJB?
  2. What have people done to work around this limitation?

My developers are about to surge forward with hard-coded JNDI lookups (e.g. context.lookup(someHardCodedNameHere)) because no one can find a workaround to this specification violation at the present time. I really want to avoid this.

Lastly, I've looked at using CDI, but the story here isn't much better as RestEasy and CDI still aren't talking to each other.

Thanks in advance for any pointers.

© Stack Overflow or respective owner

Related posts about jboss

Related posts about jax-rs