cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeyvison Nascimento (JIRA)" <>
Subject [jira] [Created] (CXF-7501) Cannot inject field in ContainerRequestFilter
Date Tue, 12 Sep 2017 17:29:00 GMT
Jeyvison Nascimento created CXF-7501:

             Summary: Cannot inject field in ContainerRequestFilter
                 Key: CXF-7501
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 3.1.10
         Environment: Linux Mint 64 bit, TomEE Plus 7.0.3, JavaEE 7 application using MVC
specification and reference implementation

            Reporter: Jeyvison Nascimento
            Priority: Critical

Hey folks.

We found a weird behavior while running MVC specification(JSR 371) on TomEE witch CXF. We
have a *ContainerRequestFilter* defined called *JaxRsContextFilter* 

public class JaxRsContextFilter implements ContainerRequestFilter {
    private JaxRsContextProducer jaxRsContextProducer;
    private Configuration configuration;
    private HttpServletRequest request;
    private HttpServletResponse response;

    public JaxRsContextFilter() {

    public void filter(ContainerRequestContext requestContext) throws IOException {
        this.jaxRsContextProducer.populate(this.configuration, this.request, this.response);

You can see that we have a JaxRsContextProducer annotated to be injected as a field in our
object but when JAXRSUtils is called to run the the container filters it injects the fields
annotated as *@Context* , not the fields annotated with *@Inject*.

 for (ProviderInfo<ContainerRequestFilter> filter : containerFilters) {
                try {
                    InjectionUtils.injectContexts(filter.getProvider(), filter, m);
                } catch (IOException ex) {
                    throw ExceptionUtils.toInternalServerErrorException(ex, null); 

It causes our filter(*JaxRsContextFilter*) to throw a NullPointerException when filtering
the request because it uses the producer to perform some actions in  this operation.

I believe this field should be injected as well, not only the *@Context* fields.

This message was sent by Atlassian JIRA

View raw message