You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kiril Gavrailov <kg...@gmail.com> on 2013/02/12 16:42:03 UTC

SeachContext not being injected properly

Hey Guys,
I have a project that uses FIQL and respectively SearchContext.
However when I migrated form cxf 2.4.10 to 2.7.3 my filtering
functionallity has stopped working.

What is the project setup?
The search context is injected with the @Context annotation as a field
variable in an abstract class, later on this abstract class is extended for
different rest resources and they all have filtering on a particular get
method.

What is the problem?
I have attached the whole exception (hope that the mailing list will show
the attachment, if no please do tell me I'll send them in the mail).

What are my outcomes so far?
When I started debugging I noticed that the searchContext variable is kept
into a threadlocal variable, but when the get() method of thread local is
invoked it returns null.
Further more the value of the threadlocalmap is null. Which means that the
context is not being injected properly.
When I continued debugging what I found is the following:
In the org.apache.cxf.jaxrs.utils.InjectionUtils class the method
injectContextFields invokes the org.apache.cxf.jaxrs.utils.JAXRSUtils
createContextValue which returns null and fails to inject the search
context.
Furthermore in the createContextValue method for the search context the
method ProviderFactory.getInstance(m).createContextProvider is invoked
which also returns null
since the contextProviders List in the
org.apache.cxf.jaxrs.provider.ProviderFactory is *empty*.

Unfortunately I'm unable to realize what's going with the contextProviders
field. So I'm asking you for your help. Do you have any idea what's going
on and why my search context is not being injected properly?

If you need any further information please do tell.

Thanks in advance.

Best Regards,
Kiril

Re: SeachContext not being injected properly

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Kiril
On 12/02/13 20:12, Kiril Gavrailov wrote:
> Oh,
> now I saw how to do it in the documentation, sorry for the dummy question
> :)

np, when using Application - return the list of providers from Application

> Will try it first thing tommorow. Big thanks for the help.
>
Thanks, Sergey

> Kiril
>
> On Tue, Feb 12, 2013 at 7:44 PM, Kiril Gavrailov<kg...@gmail.com>wrote:
>
>> Hi Sergey,
>> Thanks for the prompt response!
>> I have one more question though.
>> I use the non-spring CXFNonSpringJaxrsServlet and therefore I had to
>> register the SearchContextProvider as an init param.
>> However when I'm looking at the source of the CXFNonSpringJaxrsServlet I
>> see that it will never apply the jaxrs.providers param
>> if the javax.ws.rs.Application is set since the code says the following:
>>   String applicationClass =
>> servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
>>          if (applicationClass != null) {
>>              createServerFromApplication(applicationClass, servletConfig,
>> splitChar);
>>              return;
>>          }
>> .....
>>   List<?>  providers = getProviders(servletConfig,
>> splitChar);
>>   bean.setProviders(providers);
>>
>> So in my case I have the javax.ws.rs.Application proeprty set and the
>> setProviders method is never invoked.
>> Is there a way to pass the jaxrs.providers property as a property of the
>> application and from theare the server factory bean to see it and sets it
>> as an additional provider?
>>
>> Regards,
>> Kiril
>>
>>
>> On Tue, Feb 12, 2013 at 7:06 PM, Sergey Beryozkin<sb...@gmail.com>wrote:
>>
>>> Hi
>>>
>>> On 12/02/13 15:42, Kiril Gavrailov wrote:
>>>
>>>> Hey Guys,
>>>> I have a project that uses FIQL and respectively SearchContext.
>>>> However when I migrated form cxf 2.4.10 to 2.7.3 my filtering
>>>> functionallity has stopped working.
>>>>
>>>> What is the project setup?
>>>> The search context is injected with the @Context annotation as a field
>>>> variable in an abstract class, later on this abstract class is extended
>>>> for different rest resources and they all have filtering on a particular
>>>> get method.
>>>>
>>>> What is the problem?
>>>> I have attached the whole exception (hope that the mailing list will
>>>> show the attachment, if no please do tell me I'll send them in the mail).
>>>>
>>>> What are my outcomes so far?
>>>> When I started debugging I noticed that the searchContext variable is
>>>> kept into a threadlocal variable, but when the get() method of thread
>>>> local is invoked it returns null.
>>>> Further more the value of the threadlocalmap is null. Which means that
>>>> the context is not being injected properly.
>>>> When I continued debugging what I found is the following:
>>>> In the org.apache.cxf.jaxrs.utils.**InjectionUtils class the method
>>>> injectContextFields invokes the org.apache.cxf.jaxrs.utils.**JAXRSUtils
>>>> createContextValue which returns null and fails to inject the search
>>>> context.
>>>> Furthermore in the createContextValue method for the search context the
>>>> method ProviderFactory.getInstance(m)**.createContextProvider is invoked
>>>> which also returns null
>>>> since the contextProviders List in the
>>>> org.apache.cxf.jaxrs.provider.**ProviderFactory is *empty*.
>>>>
>>>>
>>>> Unfortunately I'm unable to realize what's going with the
>>>> contextProviders field. So I'm asking you for your help. Do you have any
>>>> idea what's going on and why my search context is not being injected
>>>> properly?
>>>>
>>>> If you need any further information please do tell.
>>>>
>>>>
>>> Thanks for trying to get to the bottom of it, FYI, given that no
>>> auto-discovery of providers is supported in CXF (I keep saying it will be
>>> but not at the moment), one has to explicitly register
>>>
>>> "org.apache.cxf.jaxrs.ext.**search.SearchContextProvider" as
>>> jaxrs:provider, this will do it
>>>
>>> Thanks, Sergey
>>>
>>>
>>>   Thanks in advance.
>>>>
>>>> Best Regards,
>>>> Kiril
>>>>
>>>
>>>
>>

Re: SeachContext not being injected properly

Posted by Kiril Gavrailov <kg...@gmail.com>.
Oh,
now I saw how to do it in the documentation, sorry for the dummy question
:)
Will try it first thing tommorow. Big thanks for the help.

Kiril

On Tue, Feb 12, 2013 at 7:44 PM, Kiril Gavrailov <kg...@gmail.com>wrote:

> Hi Sergey,
> Thanks for the prompt response!
> I have one more question though.
> I use the non-spring CXFNonSpringJaxrsServlet and therefore I had to
> register the SearchContextProvider as an init param.
> However when I'm looking at the source of the CXFNonSpringJaxrsServlet I
> see that it will never apply the jaxrs.providers param
> if the javax.ws.rs.Application is set since the code says the following:
>  String applicationClass =
> servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
>         if (applicationClass != null) {
>             createServerFromApplication(applicationClass, servletConfig,
> splitChar);
>             return;
>         }
> .....
>  List<?> providers = getProviders(servletConfig,
> splitChar);
>  bean.setProviders(providers);
>
> So in my case I have the javax.ws.rs.Application proeprty set and the
> setProviders method is never invoked.
> Is there a way to pass the jaxrs.providers property as a property of the
> application and from theare the server factory bean to see it and sets it
> as an additional provider?
>
> Regards,
> Kiril
>
>
> On Tue, Feb 12, 2013 at 7:06 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi
>>
>> On 12/02/13 15:42, Kiril Gavrailov wrote:
>>
>>> Hey Guys,
>>> I have a project that uses FIQL and respectively SearchContext.
>>> However when I migrated form cxf 2.4.10 to 2.7.3 my filtering
>>> functionallity has stopped working.
>>>
>>> What is the project setup?
>>> The search context is injected with the @Context annotation as a field
>>> variable in an abstract class, later on this abstract class is extended
>>> for different rest resources and they all have filtering on a particular
>>> get method.
>>>
>>> What is the problem?
>>> I have attached the whole exception (hope that the mailing list will
>>> show the attachment, if no please do tell me I'll send them in the mail).
>>>
>>> What are my outcomes so far?
>>> When I started debugging I noticed that the searchContext variable is
>>> kept into a threadlocal variable, but when the get() method of thread
>>> local is invoked it returns null.
>>> Further more the value of the threadlocalmap is null. Which means that
>>> the context is not being injected properly.
>>> When I continued debugging what I found is the following:
>>> In the org.apache.cxf.jaxrs.utils.**InjectionUtils class the method
>>> injectContextFields invokes the org.apache.cxf.jaxrs.utils.**JAXRSUtils
>>> createContextValue which returns null and fails to inject the search
>>> context.
>>> Furthermore in the createContextValue method for the search context the
>>> method ProviderFactory.getInstance(m)**.createContextProvider is invoked
>>> which also returns null
>>> since the contextProviders List in the
>>> org.apache.cxf.jaxrs.provider.**ProviderFactory is *empty*.
>>>
>>>
>>> Unfortunately I'm unable to realize what's going with the
>>> contextProviders field. So I'm asking you for your help. Do you have any
>>> idea what's going on and why my search context is not being injected
>>> properly?
>>>
>>> If you need any further information please do tell.
>>>
>>>
>> Thanks for trying to get to the bottom of it, FYI, given that no
>> auto-discovery of providers is supported in CXF (I keep saying it will be
>> but not at the moment), one has to explicitly register
>>
>> "org.apache.cxf.jaxrs.ext.**search.SearchContextProvider" as
>> jaxrs:provider, this will do it
>>
>> Thanks, Sergey
>>
>>
>>  Thanks in advance.
>>>
>>> Best Regards,
>>> Kiril
>>>
>>
>>
>

Re: SeachContext not being injected properly

Posted by Kiril Gavrailov <kg...@gmail.com>.
Hi Sergey,
Thanks for the prompt response!
I have one more question though.
I use the non-spring CXFNonSpringJaxrsServlet and therefore I had to
register the SearchContextProvider as an init param.
However when I'm looking at the source of the CXFNonSpringJaxrsServlet I
see that it will never apply the jaxrs.providers param
if the javax.ws.rs.Application is set since the code says the following:
 String applicationClass =
servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
        if (applicationClass != null) {
            createServerFromApplication(applicationClass, servletConfig,
splitChar);
            return;
        }
.....
 List<?> providers = getProviders(servletConfig, splitChar);
 bean.setProviders(providers);

So in my case I have the javax.ws.rs.Application proeprty set and the
setProviders method is never invoked.
Is there a way to pass the jaxrs.providers property as a property of the
application and from theare the server factory bean to see it and sets it
as an additional provider?

Regards,
Kiril

On Tue, Feb 12, 2013 at 7:06 PM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi
>
> On 12/02/13 15:42, Kiril Gavrailov wrote:
>
>> Hey Guys,
>> I have a project that uses FIQL and respectively SearchContext.
>> However when I migrated form cxf 2.4.10 to 2.7.3 my filtering
>> functionallity has stopped working.
>>
>> What is the project setup?
>> The search context is injected with the @Context annotation as a field
>> variable in an abstract class, later on this abstract class is extended
>> for different rest resources and they all have filtering on a particular
>> get method.
>>
>> What is the problem?
>> I have attached the whole exception (hope that the mailing list will
>> show the attachment, if no please do tell me I'll send them in the mail).
>>
>> What are my outcomes so far?
>> When I started debugging I noticed that the searchContext variable is
>> kept into a threadlocal variable, but when the get() method of thread
>> local is invoked it returns null.
>> Further more the value of the threadlocalmap is null. Which means that
>> the context is not being injected properly.
>> When I continued debugging what I found is the following:
>> In the org.apache.cxf.jaxrs.utils.**InjectionUtils class the method
>> injectContextFields invokes the org.apache.cxf.jaxrs.utils.**JAXRSUtils
>> createContextValue which returns null and fails to inject the search
>> context.
>> Furthermore in the createContextValue method for the search context the
>> method ProviderFactory.getInstance(m)**.createContextProvider is invoked
>> which also returns null
>> since the contextProviders List in the
>> org.apache.cxf.jaxrs.provider.**ProviderFactory is *empty*.
>>
>>
>> Unfortunately I'm unable to realize what's going with the
>> contextProviders field. So I'm asking you for your help. Do you have any
>> idea what's going on and why my search context is not being injected
>> properly?
>>
>> If you need any further information please do tell.
>>
>>
> Thanks for trying to get to the bottom of it, FYI, given that no
> auto-discovery of providers is supported in CXF (I keep saying it will be
> but not at the moment), one has to explicitly register
>
> "org.apache.cxf.jaxrs.ext.**search.SearchContextProvider" as
> jaxrs:provider, this will do it
>
> Thanks, Sergey
>
>
>  Thanks in advance.
>>
>> Best Regards,
>> Kiril
>>
>
>

Re: SeachContext not being injected properly

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 12/02/13 15:42, Kiril Gavrailov wrote:
> Hey Guys,
> I have a project that uses FIQL and respectively SearchContext.
> However when I migrated form cxf 2.4.10 to 2.7.3 my filtering
> functionallity has stopped working.
>
> What is the project setup?
> The search context is injected with the @Context annotation as a field
> variable in an abstract class, later on this abstract class is extended
> for different rest resources and they all have filtering on a particular
> get method.
>
> What is the problem?
> I have attached the whole exception (hope that the mailing list will
> show the attachment, if no please do tell me I'll send them in the mail).
>
> What are my outcomes so far?
> When I started debugging I noticed that the searchContext variable is
> kept into a threadlocal variable, but when the get() method of thread
> local is invoked it returns null.
> Further more the value of the threadlocalmap is null. Which means that
> the context is not being injected properly.
> When I continued debugging what I found is the following:
> In the org.apache.cxf.jaxrs.utils.InjectionUtils class the method
> injectContextFields invokes the org.apache.cxf.jaxrs.utils.JAXRSUtils
> createContextValue which returns null and fails to inject the search
> context.
> Furthermore in the createContextValue method for the search context the
> method ProviderFactory.getInstance(m).createContextProvider is invoked
> which also returns null
> since the contextProviders List in the
> org.apache.cxf.jaxrs.provider.ProviderFactory is *empty*.
>
> Unfortunately I'm unable to realize what's going with the
> contextProviders field. So I'm asking you for your help. Do you have any
> idea what's going on and why my search context is not being injected
> properly?
>
> If you need any further information please do tell.
>

Thanks for trying to get to the bottom of it, FYI, given that no 
auto-discovery of providers is supported in CXF (I keep saying it will 
be but not at the moment), one has to explicitly register

"org.apache.cxf.jaxrs.ext.search.SearchContextProvider" as 
jaxrs:provider, this will do it

Thanks, Sergey

> Thanks in advance.
>
> Best Regards,
> Kiril