Or register the validation feature directly on the server endpoint
Sergey On 24/10/16 13:10, Sergey Beryozkin wrote:
Hi This is caused by the fact that a server-scoped feature is visible to a client because this feature is set on a bus visible to the client. I've just updated the code for this feature be explicitly marked as a Server scoped feature - but it will only help for now if the features are auto-discovered. The CXF core code may need to be updated to exclude the CXF providers which are out of scope (ex, the server is being initialized and a client only feature is available or vice versa) I'll have a look at it a bit later on For now create a dedicated bus for the client test code Thanks, Sergey On 23/10/16 17:10, Johannes Fiala wrote:Hi there, cxf-spring-boot-starter-jaxrs: 3.1.7 I tried using Spring Boot CXF in combination with Spring Boot integration tests (running as a Spring Boot application everything runs fine without exceptions): As soon as the BeanValidation Feature is enabled: <bean id="commonValidationFeature" class="org.apache.cxf.validation.BeanValidationFeature"/> <cxf:bus> <cxf:features> <ref bean="commonValidationFeature" /> </cxf:features> </cxf:bus> running an integration test ============================ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringBootApplication.class) @WebAppConfiguration @IntegrationTest("server.port=0") public class HelloApiTest { @Value("${local.server.port}") private int serverPort; private HelloApi api; @Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services/services", HelloApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); } @Test public void helloPostTest() { String name = "name"; String response = api.sayHello(name); System.out.println("response: " + response); assertNotNull(response); } ============================ will show the following error after the response has been received (the test itself is green, a valid response is received): 2016-10-23 17:54:37.145 ERROR 4556 --- [ main] o.a.c.v.AbstractValidationInterceptor : Service Object is null 2016-10-23 17:54:37.148 WARN 4556 --- [ main] o.a.cxf.phase.PhaseInterceptorChain : Interceptor for {http://api.swagger.io/}HelloApi has thrown exception, unwinding now javax.validation.ValidationException: Service Object is null at org.apache.cxf.validation.BeanValidationInInterceptor.checkNotNull(BeanValidationInInterceptor.java:49) ~[cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.validation.BeanValidationInInterceptor.getServiceObject(BeanValidationInInterceptor.java:38) ~[cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.validation.AbstractValidationInterceptor.handleMessage(AbstractValidationInterceptor.java:59) ~[cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.jaxrs.client.ClientMessageObserver.onMessage(ClientMessageObserver.java:56) [cxf-rt-rs-client-3.1.7.jar:3.1.7] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1670) [cxf-rt-transports-http-3.1.7.jar:3.1.7] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1551) [cxf-rt-transports-http-3.1.7.jar:3.1.7] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1348) [cxf-rt-transports-http-3.1.7.jar:3.1.7] at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56) [cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:216) [cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) [cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:651) [cxf-rt-transports-http-3.1.7.jar:3.1.7] at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) [cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.1.7.jar:3.1.7] at org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:666) [cxf-rt-rs-client-3.1.7.jar:3.1.7] at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:744) [cxf-rt-rs-client-3.1.7.jar:3.1.7] at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:231) [cxf-rt-rs-client-3.1.7.jar:3.1.7] response: Hello name This is not causing any errors, its only a bit odd to see the exception in the tests... Best regards, Johannes
-- Sergey Beryozkin Talend Community Coders http://coders.talend.com/
