cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fadi Mohsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-5689) NPE at ThreadLocalProviders.getContextResolver()
Date Mon, 12 Oct 2015 20:37:05 GMT

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

Fadi Mohsen commented on CXF-5689:
----------------------------------

[~sergey_beryozkin] thank you for explaining
Ill try out below and dig more examples on CXF + Jackson.
{code}
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setProviders(Arrays.asList(new JacksonJaxbJsonProvider(){
        	protected ObjectMapper _locateMapperViaProvider(Class<?> type, MediaType mediaType)
{
        		return new ObjectMapper();
        	}
        }));

        Map<Class<?>, ?> resources = getResources();
        for (Map.Entry<Class<?>, ?> entry : resources.entrySet()) {
            sf.setResourceClasses(entry.getKey());
            sf.setResourceProvider(entry.getKey(), new SingletonResourceProvider(entry.getValue()));
        }
....
       sf.create()
{code}

> NPE at ThreadLocalProviders.getContextResolver()
> ------------------------------------------------
>
>                 Key: CXF-5689
>                 URL: https://issues.apache.org/jira/browse/CXF-5689
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.11
>            Reporter: Hooman Valibeigi
>            Assignee: Sergey Beryozkin
>             Fix For: 3.0.0, 2.7.12
>
>
> I have extensions of the following classes in my application used as providers when creating
jaxrs clients or servers.
> javax.ws.rs.ext.ContextResolver
> javax.ws.rs.ext.MessageBodyReader
> javax.ws.rs.ext.MessageBodyWriter
> javax.ws.rs.ext.ExceptionMapper
> org.apache.cxf.jaxrs.client.ResponseExceptionMapper
> All my custom providers have the following member field injected at runtime.
> @Context private Providers providers;
> Within the providers' methods I'm calling this:
> providers.getContextResolver(aClass, aMediaType);
> This is causing a NullPointerException for the ResponseExceptionMapper. All the other
providers have no problem getting the context resolver.
> java.lang.NullPointerException
>         at org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders.getContextResolver(ThreadLocalProviders.java:50)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message