Hi Sergey,
Thanks, I tried the code snippet you suggested. I have gotten further,
however it looks like I've uncovered a bug in the WebClient code.
When using the local transport, an NPE is thrown from the
AbstractClient class (line 386)
381. Map<String, List<Object>> protocolHeaders =
CastUtils.cast((Map<?,
?>)responseMessage.get(Message.PROTOCOL_HEADERS));
boolean splitHeaders =
MessageUtils.isTrue(outMessage.getContextualProperty(HEADER_SPLIT_PROPERTY));
386. for (Map.Entry<String, List<Object>> entry :
protocolHeaders.entrySet()) {
This is because protocolHeaders evaluates to null in 381, causing the
NPE in 386. This is for local transport only, when using the http
transport, it works fine.
Should I log a defect for this?
Regards
Kiren
On Thu, Aug 7, 2014 at 9:49 PM, Sergey Beryozkin <[email protected]> wrote:
> Hi,
>
> Can you have a look at JAXRSLocalTransportTest in systests/jaxrs ?
> It has this test:
>
> @Test
> public void testWebClientDirectDispatch() throws Exception {
> WebClient localClient = WebClient.create("local://books");
> localClient.path("bookstore/books/123");
> Book book = localClient.get(Book.class);
> assertEquals(123L, book.getId());
> }
>
> Can you please try the following, create WebClient directly in the code,
> without injecting it, and see if it can invoke correctly,just to check if it
> is an injection related issue or not.
>
> Cheers, Sergey
>
>
>
> On 07/08/14 19:36, Kiren Pillay wrote:
>>
>> I thought serviceClass with the actual Rest service implementation,
>> sorry!:)
>> The following fixed this:
>>
>> <jaxrs-client:client id="webClient" address="local://rsservice"
>> serviceClass="org.apache.cxf.jaxrs.client.WebClient" >
>>
>>
>> I managed to get further now, the client is calling the service via
>> the local transport, however I'm getting the following error.
>>
>> " Local destination does not have a MessageObserver on address
>> local://rsservice/function/msisdnLessSim"
>>
>> I upgraded to 3.0.1 now thinking it would solve the problem but its
>> still there:/
>>
>> On Thu, Aug 7, 2014 at 3:19 PM, Sergey Beryozkin <[email protected]>
>> wrote:
>>>
>>> Hi Kiren
>>>
>>> I'm not sure yet I follow :-) but yes, jaxrs:client/@serviceClass can be
>>> set
>>> to a full WebClient name -> it will lead to a WebClient created.
>>> WebClient can work with a local transport too
>>>
>>> Cheers, Sergey
>>>
>>> On 07/08/14 16:16, Kiren Pillay wrote:
>>>>
>>>>
>>>> Hi Sergey,
>>>>
>>>> Not sure if I'm the right track.
>>>>
>>>> What I need is to enable the following scenario.
>>>>
>>>> Client ----> JAXRSEntryService -----+-------> JAXTargetResource1
>>>> |
>>>> |+------->
>>>> JAXTargetResource-n
>>>>
>>>> The Entry service will perform a table lookup of the target resource's
>>>> path based on an input parameter from the external client. I would
>>>> then use the client in the JAXRSEntryService to call the target
>>>> resources using the local transport. The target resources are all in
>>>> the same Spring container.
>>>>
>>>> Specifying the ServiceClass means I know the target resource I'm
>>>> calling upfront? In this case I don't know it. What's the best
>>>> approach to do this. Do I just create a webclient and use the local
>>>> transport in the URL?
>>>>
>>>> Regards
>>>> Kiren
>>>>
>>>> On Thu, Aug 7, 2014 at 2:18 PM, Sergey Beryozkin <[email protected]>
>>>> wrote:
>>>>>
>>>>>
>>>>> Hi Kiren
>>>>> Looks like a jaxrs:client/@serviceClass is missing
>>>>>
>>>>> Cheers, Sergey
>>>>>
>>>>> On 07/08/14 14:25, Kiren Pillay wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi Sergey,
>>>>>>
>>>>>> I'm trying to use the local transport as outlined in our email before.
>>>>>>
>>>>>> I can't seem to get the client injected into my Service bean (I'm
>>>>>> using
>>>>>> 2.7.7).
>>>>>>
>>>>>> <!-- local transport -->
>>>>>> <jaxrs:server id="localRestContainer"
>>>>>> address="local://rsservice"
>>>>>> transportId="http://cxf.apache.org/transports/local">
>>>>>> <jaxrs:serviceBeans>
>>>>>> <ref bean="msisdnLessSimService" />
>>>>>> </jaxrs:serviceBeans>
>>>>>> <jaxrs:providers>
>>>>>> <ref bean="jaxbProvider" />
>>>>>> <ref bean="pamsExceptionMapper" />
>>>>>> <ref bean="pamsRuntimeExceptionMapper" />
>>>>>> </jaxrs:providers>
>>>>>>
>>>>>> <jaxrs:invoker>
>>>>>> <bean
>>>>>> class="za.co.vodacom.pams.bs.WebServiceAuthorizationInvoker" />
>>>>>> </jaxrs:invoker>
>>>>>> </jaxrs:server>
>>>>>>
>>>>>> <!-- Local transport -->
>>>>>> <jaxrs:client id="webClient" address="local://rsservice" >
>>>>>> </jaxrs:client>
>>>>>> <bean id="pamsInfo"
>>>>>> class="za.co.vodacom.pams.bs.info.PAMSInfoServiceImpl">
>>>>>> <property name="webClient" ref="webClient"></property>
>>>>>> </bean>
>>>>>>
>>>>>> [ContextLoader]initWebApplicationContext(main) 308
>>>>>> org.springframework.beans.factory.BeanCreationException: Error
>>>>>> creating bean with name 'webClient': Instantiation of bean failed;
>>>>>> nested exception is
>>>>>> org.springframework.beans.factory.BeanDefinitionStoreException:
>>>>>> Factory method [public org.apache.cxf.jaxrs.client.Client
>>>>>> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create()] threw
>>>>>> exception; nested exception is javax.ws.rs.NotFoundException
>>>>>> at
>>>>>>
>>>>>>
>>>>>> org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
>>>>>> at
>>>>>>
>>>>>>
>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)
>>>>>> at
>>>>>>
>>>>>>
>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
>>>>>>
>>>>>> On Sun, Nov 17, 2013 at 5:47 PM, Kiren Pillay <[email protected]>
>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Okay, I was was supposed to use "#" in front of bean name.
>>>>>>>
>>>>>>> Thx
>>>>>>>
>>>>>>>
>>>>>>> On Sun, Nov 17, 2013 at 11:42 AM, Kiren Pillay
>>>>>>> <[email protected]>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Hi Sergei,
>>>>>>>>
>>>>>>>> I'm trying to use the bean reference for the implementing class but
>>>>>>>> am
>>>>>>>> getting a classNotFoundError (CXF2.7.7). Is this a bug or is there a
>>>>>>>> special
>>>>>>>> way to reference the bean. Also, wouldn't it be better to have a
>>>>>>>> bean-ref
>>>>>>>> attribute rather than the implementor attribute?
>>>>>>>>
>>>>>>>> <bean id="soapMmsBilling"
>>>>>>>> class="za.co.vodacom.pams.soap.SoapMmsBillingRequestImpl">
>>>>>>>> <!-- Inject local client
>>>>>>>> <property name="localRestClient"
>>>>>>>> ref="localHttpClient"/>-->
>>>>>>>> </bean>
>>>>>>>>
>>>>>>>> <jaxws:endpoint id="MmsBillingSoapWebservice"
>>>>>>>> serviceName="customer:OpenWaveMmsBilling"
>>>>>>>> implementor="soapMmsBilling"
>>>>>>>> xmlns:customer="http://www.openwave.com/protocols/oip/">
>>>>>>>> <jaxws:features>
>>>>>>>> <bean class="org.apache.cxf.feature.LoggingFeature"
>>>>>>>> />
>>>>>>>> </jaxws:features>
>>>>>>>> </jaxws:endpoint>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.BeanCreationException: Error
>>>>>>>> creating
>>>>>>>> bean with name 'MmsBillingSoapWebservice': Cannot create inner bean
>>>>>>>> '(inner
>>>>>>>> bean)' of type [soapMmsBilling] while setting constructor argument;
>>>>>>>> nested
>>>>>>>> exception is
>>>>>>>> org.springframework.beans.factory.CannotLoadBeanClassException:
>>>>>>>> Cannot find class [soapMmsBilling] for bean with name '(inner
>>>>>>>> bean)#1'
>>>>>>>> defined in null; nested exception is
>>>>>>>> java.lang.ClassNotFoundException:
>>>>>>>> soapMmsBilling
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:623)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
>>>>>>>> at
>>>>>>>> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
>>>>>>>> at
>>>>>>>> org.apache.catalina.core.StandardHost.start(StandardHost.java:862)
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.StandardService.start(StandardService.java:525)
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
>>>>>>>> at
>>>>>>>> org.apache.catalina.startup.Catalina.start(Catalina.java:595)
>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>>>>>>> Method)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>>>> at java.lang.reflect.Method.invoke(Method.java:601)
>>>>>>>> at
>>>>>>>> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
>>>>>>>> at
>>>>>>>> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
>>>>>>>> Caused by:
>>>>>>>> org.springframework.beans.factory.CannotLoadBeanClassException:
>>>>>>>> Cannot find class [soapMmsBilling] for bean with name '(inner
>>>>>>>> bean)#1'
>>>>>>>> defined in null; nested exception is
>>>>>>>> java.lang.ClassNotFoundException:
>>>>>>>> soapMmsBilling
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:433)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
>>>>>>>> ... 41 more
>>>>>>>> Caused by: java.lang.ClassNotFoundException: soapMmsBilling
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
>>>>>>>> at
>>>>>>>> org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Nov 14, 2013 at 12:54 PM, Kiren Pillay
>>>>>>>> <[email protected]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks Sergey, will give it a try!
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>> Kiren
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Nov 14, 2013 at 12:36 PM, Sergey Beryozkin
>>>>>>>>> <[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Hi Kiren
>>>>>>>>>>
>>>>>>>>>> Add one more jaxrs:server endpoint with a local transport address,
>>>>>>>>>> sharing the same JAX-RS bean with the HTTP-aware jaxrs:endpoint,
>>>>>>>>>> and
>>>>>>>>>> then
>>>>>>>>>> inject a jaxrs:client or WebClient initialized with the local
>>>>>>>>>> transport
>>>>>>>>>> address into your JAX-WS server, example,
>>>>>>>>>>
>>>>>>>>>> <jaxrs:server address="/http">
>>>>>>>>>> <jaxrs:serviceBeans>
>>>>>>>>>> <ref bean="service"/>
>>>>>>>>>> </jaxrs:serviceBeans>
>>>>>>>>>> </jaxrs:server>
>>>>>>>>>>
>>>>>>>>>> <jaxrs:server address="local://rsservice"
>>>>>>>>>> transportId="http://cxf.apache.org/transports/local">
>>>>>>>>>> <jaxrs:serviceBeans>
>>>>>>>>>> <ref bean="service"/>
>>>>>>>>>> </jaxrs:serviceBeans>
>>>>>>>>>> </jaxrs:server>
>>>>>>>>>>
>>>>>>>>>> <jaxrs:client address="local://rsservice">
>>>>>>>>>> </jaxrs:client>
>>>>>>>>>>
>>>>>>>>>> and inject this client (or WebClient) into the soap server
>>>>>>>>>>
>>>>>>>>>> This should do
>>>>>>>>>>
>>>>>>>>>> Cheers, Sergey
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 13/11/13 23:10, Kiren Pillay wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Hi Sergey,
>>>>>>>>>>>
>>>>>>>>>>> I am trying to have a SOAP service calling a RESTFUL service,
>>>>>>>>>>> both
>>>>>>>>>>> deployed
>>>>>>>>>>> within the same CXF servlet.
>>>>>>>>>>>
>>>>>>>>>>> What is the best or most efficient way to invoke the RestFul
>>>>>>>>>>> service
>>>>>>>>>>> from
>>>>>>>>>>> the SOAP service?. I want the RestFul service to behave as if its
>>>>>>>>>>> being
>>>>>>>>>>> called from an external source so that the invokers etc are all
>>>>>>>>>>> called
>>>>>>>>>>> as
>>>>>>>>>>> normal.
>>>>>>>>>>>
>>>>>>>>>>> I'm trying the following call but it doesn't seem to be invoking
>>>>>>>>>>> the
>>>>>>>>>>> service. Both the SOAP and REST service are within the same
>>>>>>>>>>> Servlet
>>>>>>>>>>> Context.
>>>>>>>>>>>
>>>>>>>>>>> WebClient wc = WebClient.create(
>>>>>>>>>>>
>>>>>>>>>>> "
>>>>>>>>>>>
>>>>>>>>>>> http://localhost:8080/deploy-mms-billing/rest/function/mmsBilling",
>>>>>>>>>>> "test", "test", null);
>>>>>>>>>>>
>>>>>>>>>>> Regards
>>>>>>>>>>> Kiren
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Sergey Beryozkin
>>>>>>>>>>
>>>>>>>>>> Talend Community Coders
>>>>>>>>>> http://coders.talend.com/
>>>>>>>>>>
>>>>>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>
>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>
>