well you use:

@Provider
@Stateless
// @LocalBean <== missing
public class TestExceptionHandler
  implements ExceptionMapper<Throwable>
{

  @Context
  HttpServletRequest request;

  @EJB
  Test test;

  public Response toResponse(Throwable throwable)
  {
    System.out.println("Test ejb in exception handler = " +
this.test.sayHello(100));

    return Response.ok().build();
  }
}

so not a local bean.


you can test the resolution of your handler in a test servlet for
instance injecting the bean manager and using this code:




final Set<Bean<?>> beans = bm.getBeans(clazz);
final Bean<?> bean = bm.resolve(beans);
final CreationalContextImpl<?> creationalContext =
bm.createCreationalContext(bean);
final Object instance = bm.getReference(bean, clazz, creationalContext);
// worked, instance is your EJB




Romain Manni-Bucau
@rmannibucau |  Blog | Github | LinkedIn | Tomitriber


2015-11-19 22:06 GMT-08:00 Rentius <rentius2407...@gmail.com>:
> Thanks Romain
>
> I have copied how you configured your @Provider but still getting a null
> pointer on the bean being injected.
> Did you get my project to work, the one that I shared?
>
> ScratchPad.war
> <http://tomee-openejb.979440.n4.nabble.com/file/n4676894/ScratchPad.war>
>
>
>
> --
> View this message in context: 
> http://tomee-openejb.979440.n4.nabble.com/Injecting-EJB-into-Rest-Exception-Handler-tp4676781p4676894.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.

Reply via email to