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

David J. M. Karlsen commented on CXF-6588:
------------------------------------------

I'll try do create a stripped-down project.
Running standalone (junit-test with localtransport)

> NPE in providers.getMessageBodyReader
> -------------------------------------
>
>                 Key: CXF-6588
>                 URL: https://issues.apache.org/jira/browse/CXF-6588
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.2
>            Reporter: David J. M. Karlsen
>
> I have this ParamConverter:
> {code}
> @Provider
> @Component
> public class JacksonParamConverterProvider
>     implements ParamConverterProvider
> {
>     private final JsonMapperConfigurator jsonMapperConfigurator;
>     @Context
>     private Providers providers;
>     public JacksonParamConverterProvider()
>     {
>         ObjectMapper objectMapper = new ObjectMapper();
>         this.jsonMapperConfigurator =
>             new JsonMapperConfigurator( objectMapper, new Annotations[]{ 
> Annotations.JAXB, Annotations.JACKSON } );
>     }
>     @Override
>     public <T> ParamConverter<T> getConverter( Class<T> rawType, Type 
> genericType, Annotation[] annotations )
>     {
>         MessageBodyReader<T> messageBodyReader = 
> providers.getMessageBodyReader( rawType,
>                                                                               
>    genericType,
>                                                                               
>    annotations,
>                                                                               
>    MediaType.APPLICATION_JSON_TYPE );
>         if ( messageBodyReader == null || !messageBodyReader.isReadable( 
> rawType, genericType, annotations, MediaType.APPLICATION_JSON_TYPE ) ) {
>             return null;
>         }
>         if ( canConvert( rawType ) )
>         {
>             return new ParamConverter<T>()
>             {
>                 @Override
>                 public T fromString( String value )
>                 {
>                     ObjectReader objectReader = getObjectMapper().readerFor( 
> rawType );
>                     try
>                     {
>                         return objectReader.readValue( value );
>                     }
>                     catch ( IOException e )
>                     {
>                         throw new ProcessingException( e );
>                     }
>                 }
>                 @Override
>                 public String toString( T value )
>                 {
>                     try
>                     {
>                         return getObjectMapper().writerFor( rawType 
> ).writeValueAsString( value );
>                     }
>                     catch ( JsonProcessingException e )
>                     {
>                         throw new ProcessingException( e );
>                     }
>                 }
>             };
>         }
>         else
>         {
>             return null;
>         }
>     }
>     private ObjectMapper getObjectMapper()
>     {
>         return jsonMapperConfigurator.getConfiguredMapper();
>     }
>     private boolean isNotSimpleType( Class<?> rawType )
>     {
>         return ! ( rawType.getPackage().getName().startsWith( "java.lang" ) 
> || ClassUtils.isPrimitiveOrWrapper( rawType ) );
>     }
>     private boolean canConvert( Class<?> rawType )
>     {
>         return isNotSimpleType( rawType ) && getObjectMapper().canSerialize( 
> rawType );
>     }
> {code}
> which will get an NPE when calling getMessageBodyReader:
> {noformat}
> java.lang.NullPointerException: null
>       at 
> org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders.getMessageBodyReader(ThreadLocalProviders.java:39)
>  ~[cxf-rt-frontend-jaxrs-3.1.2.jar:3.1.2]
>       at 
> com.edb.fs.tac.jfr.srv.ws.jaxrs.JacksonParamConverterProvider.getConverter(JacksonParamConverterProvider.java:50)
>  ~[classes/:na]
>       at 
> org.apache.cxf.jaxrs.provider.ProviderFactory.createParameterHandler(ProviderFactory.java:256)
>  ~[cxf-rt-frontend-jaxrs-3.1.2.jar:3.1.2]
>       at 
> org.apache.cxf.jaxrs.client.AbstractClient.convertParamValue(AbstractClient.java:742)
>  ~[cxf-rt-rs-client-3.1.2.jar:3.1.2]
>       at 
> org.apache.cxf.jaxrs.client.AbstractClient.header(AbstractClient.java:139) 
> ~[cxf-rt-rs-client-3.1.2.jar:3.1.2]
>       at org.apache.cxf.jaxrs.client.WebClient.header(WebClient.java:846) 
> ~[cxf-rt-rs-client-3.1.2.jar:3.1.2]
>       at org.apache.cxf.jaxrs.client.WebClient.header(WebClient.java:83) 
> ~[cxf-rt-rs-client-3.1.2.jar:3.1.2]
>       at 
> com.edb.fs.tac.jfr.srv.ws.AbstractJaxRsSpringWithMocksTest.setHttpHeaders(AbstractJaxRsSpringWithMocksTest.java:109)
>  ~[test-classes/:na]
>       at 
> com.edb.fs.tac.jfr.srv.ws.AbstractJaxRsSpringWithMocksTest.getWebClient(AbstractJaxRsSpringWithMocksTest.java:63)
>  ~[test-classes/:na]
>       at 
> com.edb.fs.tac.jfr.srv.ws.AbstractJaxRsSpringWithMocksTest.getClientProxy(AbstractJaxRsSpringWithMocksTest.java:79)
>  ~[test-classes/:na]
>       at 
> com.edb.fs.tac.jfr.srv.ws.service.customer.CustomerResourceIntegrationTest.testWithComplexQueryObjectWithSubComplexTypes(CustomerResourceIntegrationTest.java:69)
>  ~[test-classes/:na]
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> ~[na:1.8.0_60]
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> ~[na:1.8.0_60]
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.8.0_60]
>       at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>  ~[junit-4.12.jar:4.12]
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>  ~[junit-4.12.jar:4.12]
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>  ~[junit-4.12.jar:4.12]
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>  ~[junit-4.12.jar:4.12]
>       at 
> org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
>  ~[spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at 
> org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:85)
>  ~[spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) 
> ~[junit-4.12.jar:4.12]
>       at org.junit.rules.RunRules.evaluate(RunRules.java:20) 
> [junit-4.12.jar:4.12]
>       at 
> org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:86)
>  [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 
> [junit-4.12.jar:4.12]
>       at 
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:241)
>  [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at 
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
>  [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
> [junit-4.12.jar:4.12]
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
> [junit-4.12.jar:4.12]
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
> [junit-4.12.jar:4.12]
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
> [junit-4.12.jar:4.12]
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
> [junit-4.12.jar:4.12]
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 
> [junit-4.12.jar:4.12]
>       at 
> org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
>  [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at 
> org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
>  [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
> [junit-4.12.jar:4.12]
>       at 
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
>  [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
>       at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
> [junit-4.12.jar:4.12]
>       at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
>  [junit-rt.jar:na]
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
>  [junit-rt.jar:na]
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) 
> [junit-rt.jar:na]
> {noformat}
> I am running with localtransport.



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

Reply via email to