cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-7501) Cannot inject field in ContainerRequestFilter
Date Sun, 29 Oct 2017 18:30:00 GMT

    [ https://issues.apache.org/jira/browse/CXF-7501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16224132#comment-16224132
] 

ASF GitHub Bot commented on CXF-7501:
-------------------------------------

johnament commented on issue #330: CXF-7501: Cannot inject field in ContainerRequestFilter
(and generally, into any providers registered using FeatureContext)
URL: https://github.com/apache/cxf/pull/330#issuecomment-340283415
 
 
   In general, there are no issues using CXF with CDI 2, the integration continues to work
fine.  This was just something I noticed and wanted to confirm as a real issue.
   
   `@Vetoed` was the easiest way I had to explain where it would fail from a mobile 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Cannot inject field in ContainerRequestFilter
> ---------------------------------------------
>
>                 Key: CXF-7501
>                 URL: https://issues.apache.org/jira/browse/CXF-7501
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.10, 3.2.0
>         Environment: Linux Mint 64 bit, TomEE Plus 7.0.3, JavaEE 7 application using
MVC specification and reference implementation(Libs Attached)
>            Reporter: Jeyvison Nascimento
>            Assignee: Andriy Redko
>              Labels: cdi
>             Fix For: 3.1.14, 3.2.1
>
>         Attachments: javax-mvc.jar, ozark.jar
>
>
> Hey folks.
> We found a weird behavior while running MVC specification(JSR 371) on TomEE witch CXF.
We have a *ContainerRequestFilter* defined called *JaxRsContextFilter* 
> {code:java}
> @PreMatching
> @Priority(0)
> public class JaxRsContextFilter implements ContainerRequestFilter {
>     @Inject
>     private JaxRsContextProducer jaxRsContextProducer;
>     @Context
>     private Configuration configuration;
>     @Context
>     private HttpServletRequest request;
>     @Context
>     private HttpServletResponse response;
>     public JaxRsContextFilter() {
>     }
>     public void filter(ContainerRequestContext requestContext) throws IOException {
>         this.jaxRsContextProducer.populate(this.configuration, this.request, this.response);
>     }
> }
> {code}
> 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*.
> {code:java}
>  for (ProviderInfo<ContainerRequestFilter> filter : containerFilters) {
>                 try {
>                     InjectionUtils.injectContexts(filter.getProvider(), filter, m);
>                     filter.getProvider().filter(context);
>                 } catch (IOException ex) {
>                     throw ExceptionUtils.toInternalServerErrorException(ex, null); 
>                 }
> {code}
> 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
(v6.4.14#64029)

Mime
View raw message