JAX-RS failed to inject @EJB or @Inject

后端 未结 1 1612
小蘑菇
小蘑菇 2021-01-19 06:27

I\'m trying to test a minimal JAX-RS + EJB/CDI injection mechanism and currently hitting a road-block due to GlassFish unable to inject for whatever reason.

(Using @

相关标签:
1条回答
  • 2021-01-19 07:08

    Indeed, Jersey does not handle properly dependency injection. So far it seems to be reported and aimed for future releases. http://java.net/jira/browse/JERSEY-517

    Facing same issue I had to implement context lookup to get access to managed resource.

    So try something like this in your WS constructor:

    employeeService = (ApplicationScopedEmployeeServiceImpl) new
                       InitialContext().lookup("java:global/EJB/EmployeeService");
    
    0 讨论(0)
提交回复
热议问题