You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Christian Kaltepoth (JIRA)" <ji...@apache.org> on 2017/08/31 15:56:01 UTC
[jira] [Created] (TOMEE-2122) CDI injection into dynamically
registered JAX-RS providers fails
Christian Kaltepoth created TOMEE-2122:
------------------------------------------
Summary: CDI injection into dynamically registered JAX-RS providers fails
Key: TOMEE-2122
URL: https://issues.apache.org/jira/browse/TOMEE-2122
Project: TomEE
Issue Type: Bug
Affects Versions: 7.0.2
Environment: JDK 1.8.0_141-b16, Apache Tomcat (TomEE)/8.5.6 (7.0.2)
Reporter: Christian Kaltepoth
If JAX-RS providers are registered dynamically using a {{Feature}}, CDI injection into the provider doesn't work.
If you for example annotate a {{ContainerRequestFilter}} with {{@Provider}}, injection works
fine!
{code:java}
@Provider
public class MyFilter implements ContainerRequestFilter {
@Inject
private SomeBean someBean;
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
System.out.println("Injected: " + someBean); // injection works fine!!!
}
}
{code}
Now remove the {{@Provider}} annotation and add a {{Feature}} which registers the provider:
{code:java}
@Provider
public class MyFeature implements Feature {
@Override
public boolean configure(FeatureContext featureContext) {
featureContext.register(MyFilter.class);
return true;
}
}
public class MyFilter implements ContainerRequestFilter {
@Inject
private SomeBean someBean;
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
System.out.println("Injected: " + someBean); // NULL
}
}
{code}
In this case injection does not work at all!
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)