Hi

Looks like it is actually a client side error, pass a Collections.singetonList(new JacksonJaxbJsonProvider()) to JAXRSClientFactory and the test should pass
HTH, Sergey

On 15/02/15 20:08, David Karlsen wrote:
Yes they are (it's the same classpath as when running as a standalone .war
in a container). The problem only arises when testing under localtransport.

2015-02-13 17:54 GMT+01:00 Andrei Shakirin <[email protected]>:

Hi,

Could you double check that Jackson provider jars are on the classpath?

Regards,
Andrei.

-----Original Message-----
From: David Karlsen [mailto:[email protected]]
Sent: Freitag, 13. Februar 2015 11:07
To: [email protected]
Subject: Problem marshalling responses when using LocalTransport for
intgration testing

Hi.

I'm using the localtransport to do integration testing of my JAX-RS
resources.

I setup the server like this:

private <T> void setupResource( T resource ) {
     try
     {
         PropertyUtils.setProperty( resource, "contextHolder",
contextHolder );
     }
     catch ( Exception e ) {
         logger.warn( "No property for setting contextHolder", e );
     }

     JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();

     List<Object> providers = new ArrayList<>();
     providers.add( new JacksonJaxbJsonProvider() );
     providers.add( new ServiceExceptionMapper() );
     //providers.add( new ContextHolder() ); //?
     sf.setProviders( providers );

     sf.setResourceClasses( resource.getClass() );
     sf.setResourceProvider( resource.getClass(),
         new SingletonResourceProvider( resource, true ));
     sf.setAddress( ENDPOINT_ADDRESS );

     server = sf.create();
}


And get my client like this:

protected <T> T getClientProxy( Class<T> resourceClass ) {
     T client = JAXRSClientFactory.create( ENDPOINT_ADDRESS,resourceClass
);
     WebClient.getConfig( client )
         .getRequestContext().put( LocalConduit.DIRECT_DISPATCH,
Boolean.TRUE);

     return client;
}


Invocation is OK on the server side, but when it's about to marshal the
response
it says:

No message body reader has been found for class <myPojo>, ContentType:
application/json


even though I've set the JacksonJaxbJsonProvider in the provider list.

When running a standalone server in a servlet-container it works just
fine.
What am I missing?



--
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen





Reply via email to