You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by rkam <ra...@gmail.com> on 2009/10/16 00:07:19 UTC

Multiple Custom Providers

I have two services registered.  
	

<jaxrs:server id="syncService" address="/sync">
    	<jaxrs:serviceBeans>
      			<ref bean="syncServiceBean" />
    	</jaxrs:serviceBeans>
		<jaxrs:providers>
			<ref bean="syncRequestReader"/>
			<ref bean="downloadWriter"/>
			<ref bean="profilePolicyReaderProvider"/>
		</jaxrs:providers>
	</jaxrs:server>

<jaxrs:server id="policyService" address="/policy">
    	<jaxrs:serviceBeans>
      			<ref bean="mobilePhonePolicyQueryService"/>
    	</jaxrs:serviceBeans>
		<jaxrs:providers>
			<ref bean="profilePolicyReaderProvider"/>
			<ref bean="profilePolicyWriterProvider"/>
		</jaxrs:providers>
	</jaxrs:server>
	
         <bean id="syncRequestReader"
class="biz.neustar.panjika.server.dto.SyncRequestReaderProvider"/>	

  	<bean id="downloadWriter"
class="biz.neustar.panjika.server.dto.DownloadWriterProvider"/>

         <bean id="profilePolicyReaderProvider"
class="biz.neustar.panjika.policy.dto.ProfilePolicyReaderProvider"/>	
  	<bean id="profilePolicyWriterProvider"
class="biz.neustar.panjika.policy.dto.ProfilePolicyWriterProvider"/>


Sync Service is using a reader/writer provider and while PolicyService has
its own two providers. Both work independently fine.  

But When Sync Service uses PolicyService using the Client API, I am getting
the following error even though I am registering reader within the sync
service.

SEVERE: .No message body reader found for class : class
biz.neustar.panjika.policy.dto.ProfilePolicy, ContentType : {1}.
javax.ws.rs.WebApplicationException
	at
org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:450)
	at
org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:410)
	at
org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:422)
	at
org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:404)
	at
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:163)
	at
org.apache.cxf.common.util.CglibProxyHelper$1.intercept(CglibProxyHelper.java:66)
	at
biz.neustar.panjika.policy.MobilePhonePolicyQueryService$$EnhancerByCGLIB$$ad5a408f.isPublished(<generated>)

Any help is greatly appreciated.

Thanks
rkam
  	

-- 
View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25916823.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by rkam <ra...@gmail.com>.
Also, I get a similar message that 'no message body reader found' when I am
registering more  than 2 providers for custom types.   I simply end up using
a different end point..i mean more jaxrs:server for those other types.

I am using xmlbeans  and I have reader/writer provider for every type in my
xsd.   Some intra service messaging requires that one jaxrs:server
read/write different types.

What is effect on performance.  I have about 10-15 end points and I see
things slowing down a little bit as I keep adding

Thanks
rkam



-- 
View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926008.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Multiple Custom Providers

Posted by Sergey Beryozkin <sb...@progress.com>.
Actually, we don't even need a collocates support for jaxrs:clients
because we don't want to use them when invoking on a bean living in the
same context. I should've thought about it earlier.

So given than in your case you'd like to invoke on the local bean then
just add a setter like setReference(HelloWorld hw) and just refer to a
local bean from Spring, when setting this property. If that other bean
implements the interface then it will just work. This will work well in
OSGI too

Cheers, Sergey



-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com] 
Sent: 13 November 2009 18:10
To: users@cxf.apache.org
Subject: RE: Multiple Custom Providers

Hi, 

Unfortunately I won't have it done for 2.2.5.
Will try to add the support for collocated and jms transports in time
for 2.3

Thanks, Sergey


-----Original Message-----
From: rkam [mailto:rajesh.kamineni@gmail.com] 
Sent: 13 November 2009 18:05
To: users@cxf.apache.org
Subject: Re: Multiple Custom Providers


Sergey

Are we getting the co-location feature any time soon?  Thanks for the
reply

rkam



rkam wrote:
> 
> I have two services registered.  
> 	
> 
> <jaxrs:server id="syncService" address="/sync">
>     	<jaxrs:serviceBeans>
>       			<ref bean="syncServiceBean" />
>     	</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref bean="syncRequestReader"/>
> 			<ref bean="downloadWriter"/>
> 			<ref bean="profilePolicyReaderProvider"/>
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 
> <jaxrs:server id="policyService" address="/policy">
>     	<jaxrs:serviceBeans>
>       			<ref
bean="mobilePhonePolicyQueryService"/>
>     	</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref bean="profilePolicyReaderProvider"/>
> 			<ref bean="profilePolicyWriterProvider"/>
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 	
>          <bean id="syncRequestReader"
> class="biz.neustar.panjika.server.dto.SyncRequestReaderProvider"/>	
> 
>   	<bean id="downloadWriter"
> class="biz.neustar.panjika.server.dto.DownloadWriterProvider"/>
> 
>          <bean id="profilePolicyReaderProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyReaderProvider"/>	
>   	<bean id="profilePolicyWriterProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyWriterProvider"/>
> 
> 
> Sync Service is using a reader/writer provider and while PolicyService
has
> its own two providers. Both work independently fine.  
> 
> But When Sync Service uses PolicyService using the Client API, I am
> getting the following error even though I am registering reader within
the
> sync service.
> 
> SEVERE: .No message body reader found for class : class
> biz.neustar.panjika.policy.dto.ProfilePolicy, ContentType : {1}.
> javax.ws.rs.WebApplicationException
> 	at
>
org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(Abstra
ctClient.java:450)
> 	at
>
org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:
410)
> 	at
>
org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyIm
pl.java:422)
> 	at
>
org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientPr
oxyImpl.java:404)
> 	at
>
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:
163)
> 	at
>
org.apache.cxf.common.util.CglibProxyHelper$1.intercept(CglibProxyHelper
.java:66)
> 	at
>
biz.neustar.panjika.policy.MobilePhonePolicyQueryService$$EnhancerByCGLI
B$$ad5a408f.isPublished(<generated>)
> 
> Any help is greatly appreciated.
> 
> Thanks
> rkam
>   	
> 
> 

-- 
View this message in context:
http://old.nabble.com/Multiple-Custom-Providers-tp25916823p26340777.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Multiple Custom Providers

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi, 

Unfortunately I won't have it done for 2.2.5.
Will try to add the support for collocated and jms transports in time
for 2.3

Thanks, Sergey


-----Original Message-----
From: rkam [mailto:rajesh.kamineni@gmail.com] 
Sent: 13 November 2009 18:05
To: users@cxf.apache.org
Subject: Re: Multiple Custom Providers


Sergey

Are we getting the co-location feature any time soon?  Thanks for the
reply

rkam



rkam wrote:
> 
> I have two services registered.  
> 	
> 
> <jaxrs:server id="syncService" address="/sync">
>     	<jaxrs:serviceBeans>
>       			<ref bean="syncServiceBean" />
>     	</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref bean="syncRequestReader"/>
> 			<ref bean="downloadWriter"/>
> 			<ref bean="profilePolicyReaderProvider"/>
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 
> <jaxrs:server id="policyService" address="/policy">
>     	<jaxrs:serviceBeans>
>       			<ref
bean="mobilePhonePolicyQueryService"/>
>     	</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref bean="profilePolicyReaderProvider"/>
> 			<ref bean="profilePolicyWriterProvider"/>
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 	
>          <bean id="syncRequestReader"
> class="biz.neustar.panjika.server.dto.SyncRequestReaderProvider"/>	
> 
>   	<bean id="downloadWriter"
> class="biz.neustar.panjika.server.dto.DownloadWriterProvider"/>
> 
>          <bean id="profilePolicyReaderProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyReaderProvider"/>	
>   	<bean id="profilePolicyWriterProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyWriterProvider"/>
> 
> 
> Sync Service is using a reader/writer provider and while PolicyService
has
> its own two providers. Both work independently fine.  
> 
> But When Sync Service uses PolicyService using the Client API, I am
> getting the following error even though I am registering reader within
the
> sync service.
> 
> SEVERE: .No message body reader found for class : class
> biz.neustar.panjika.policy.dto.ProfilePolicy, ContentType : {1}.
> javax.ws.rs.WebApplicationException
> 	at
>
org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(Abstra
ctClient.java:450)
> 	at
>
org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:
410)
> 	at
>
org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyIm
pl.java:422)
> 	at
>
org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientPr
oxyImpl.java:404)
> 	at
>
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:
163)
> 	at
>
org.apache.cxf.common.util.CglibProxyHelper$1.intercept(CglibProxyHelper
.java:66)
> 	at
>
biz.neustar.panjika.policy.MobilePhonePolicyQueryService$$EnhancerByCGLI
B$$ad5a408f.isPublished(<generated>)
> 
> Any help is greatly appreciated.
> 
> Thanks
> rkam
>   	
> 
> 

-- 
View this message in context:
http://old.nabble.com/Multiple-Custom-Providers-tp25916823p26340777.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by rkam <ra...@gmail.com>.
Sergey

Are we getting the co-location feature any time soon?  Thanks for the reply

rkam



rkam wrote:
> 
> I have two services registered.  
> 	
> 
> <jaxrs:server id="syncService" address="/sync">
>     	<jaxrs:serviceBeans>
>       			<ref bean="syncServiceBean" />
>     	</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref bean="syncRequestReader"/>
> 			<ref bean="downloadWriter"/>
> 			<ref bean="profilePolicyReaderProvider"/>
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 
> <jaxrs:server id="policyService" address="/policy">
>     	<jaxrs:serviceBeans>
>       			<ref bean="mobilePhonePolicyQueryService"/>
>     	</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref bean="profilePolicyReaderProvider"/>
> 			<ref bean="profilePolicyWriterProvider"/>
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 	
>          <bean id="syncRequestReader"
> class="biz.neustar.panjika.server.dto.SyncRequestReaderProvider"/>	
> 
>   	<bean id="downloadWriter"
> class="biz.neustar.panjika.server.dto.DownloadWriterProvider"/>
> 
>          <bean id="profilePolicyReaderProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyReaderProvider"/>	
>   	<bean id="profilePolicyWriterProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyWriterProvider"/>
> 
> 
> Sync Service is using a reader/writer provider and while PolicyService has
> its own two providers. Both work independently fine.  
> 
> But When Sync Service uses PolicyService using the Client API, I am
> getting the following error even though I am registering reader within the
> sync service.
> 
> SEVERE: .No message body reader found for class : class
> biz.neustar.panjika.policy.dto.ProfilePolicy, ContentType : {1}.
> javax.ws.rs.WebApplicationException
> 	at
> org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:450)
> 	at
> org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:410)
> 	at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:422)
> 	at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:404)
> 	at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:163)
> 	at
> org.apache.cxf.common.util.CglibProxyHelper$1.intercept(CglibProxyHelper.java:66)
> 	at
> biz.neustar.panjika.policy.MobilePhonePolicyQueryService$$EnhancerByCGLIB$$ad5a408f.isPublished(<generated>)
> 
> Any help is greatly appreciated.
> 
> Thanks
> rkam
>   	
> 
> 

-- 
View this message in context: http://old.nabble.com/Multiple-Custom-Providers-tp25916823p26340777.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,

>
>> It ignores profilePolicyReaderProvider for a CustomType ProfilePolicy and
>> gives me an error that no message reader is found.
>
> I'm still confused about this one. Does the jaxrs:server with the address
> "/sync" ever receives ProfilePolicy ? Or is it jaxrs:client which receives
> it ?

Or perhaps, you have types like ProfilePolicy and SuperProfilePolicy which extends ProfilePolicy ? If yes then it will definitely 
work in 2.3-SNAPSHOT and indeed in 2.4, even though sorting message body providers by types they suppor is a jaxrs 1.1. requirement

If not then if you can send me two sample providers and a resource class then it would help in narrowing the problem down

cheers, Sergey

>
> cheers, SErgey
>
>
>
> rkam wrote:
>>
>> I declared as follows in my class.  ui doesn't get set when called thru
>> jaxrs:client but works fines otherwise.
>>
>>         private UriInfo ui;
>>
>> @Context
>> public void setUriInfo(UriInfo ui) {
>> this.ui = ui;
>> }
>>
>> Also, when a jaxrs server contains multiple providers for different custom
>> types, it kind of ignores if there are is more than 1 type.
>>
>> for ex
>>
>>         <jaxrs:server id="syncService" address="/sync">
>>          <jaxrs:serviceBeans>
>>       <ref bean="syncServiceBean" />
>>         </jaxrs:serviceBeans>
>>     <jaxrs:features>
>>      <cxf:logging/>
>> </jaxrs:features>
>> <jaxrs:providers>
>> <ref bean="syncRequestReader"/>  <!-- for reading type SyncRequest-->
>> <ref bean="downloadWriter"/>        <!-- for writing type
>> DownloadSyncResponse -->
>>                         <ref bean="profilePolicyReaderProvider"/> <!-- for
>> reading ProfilePolicy type-->
>> </jaxrs:providers>
>> </jaxrs:server>
>>
>> It ignores profilePolicyReaderProvider for a CustomType ProfilePolicy and
>> gives me an error that no message reader is found.  This limits the
>> ability for an endpoint to read/write different custom types.
>>
>> Yeah.. I have to check out continuations.
>>
>> Version: 2.2.3     Project work started from 2.1.x
>>
>>
>> Sergey Beryozkin-2 wrote:
>>>
>>>
>>>>
>>>> No, UriInfo was not set and was giving null pointer .. So I had to check
>>>> Null
>>>> Pointer before I used it
>>>
>>> I'd really appreciate if you could give more infor about it (send me some
>>> code please showing how UriInfo is declared, is it
>>> injected as a filed, etc). I have a WebClient test which uses
>>> XSLTJaxbProvider on the inbound path, as a reader and it can get
>>> access to an injected UriInfo (though through a MessageContext). May be I
>>> need to add another test with a jaxrs:client being
>>> involved...
>>> By the way, what CXF version you're using ?
>>>
>>>
>>>>
>>>> I was under the assumption that ClientAPI uses colocation .. may be not
>>>> yet.
>>>> But for intra service messaging we definitely want colocation rather
>>>> than go
>>>> down the tcp stack.
>>>
>>> sure...
>>>
>>>>
>>>> Also, can you please comment on the other question I had in the same
>>>> thread.
>>>
>>> about performance ? I guess the fact that jaxrs:clients use TCP affects
>>> the performance a bit...
>>> By the way, perhaps it's on overkill for your case, but have you thought
>>> about using continuations in your service code ?
>>>
>>> cheers, Sergey
>>>
>>>>
>>>> Thanks a lot for the quick response
>>>>
>>>> rkam
>>>>
>>>>
>>>>
>>>> Sergey Beryozkin-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>>
>>>>>>
>>>>>> jaxrs:client solution that you have provided worked perfectly fine.
>>>>>
>>>>> great...
>>>>>
>>>>>> I had to do a NP check on the UriInfo
>>>>>
>>>>> can you give me some more info please ? Is it not injected into your
>>>>> custom reader when the jaxrs client starts processing the
>>>>> response ?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Now, I get the colocation performance benefit.
>>>>>
>>>>> Unfortunately not, not yet... I think it still goes over HTTP at the
>>>>> moment - one of the tasks for 2.3 is to support a local
>>>>> transport for JAXRS as well
>>>>>
>>>>> cheers, Sergey
>>>>>
>>>>>>
>>>>>> rkam
>>>>>> -- 
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25928219.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25932338.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 


Re: Multiple Custom Providers

Posted by Sergey Beryozkin <se...@iona.com>.
ok, I'll investigate the problem with setting UriInfo in readers used as part
of processing jaxrs:client invocations...

> It ignores profilePolicyReaderProvider for a CustomType ProfilePolicy and
> gives me an error that no message reader is found.

I'm still confused about this one. Does the jaxrs:server with the address
"/sync" ever receives ProfilePolicy ? Or is it jaxrs:client which receives
it ?

cheers, SErgey



rkam wrote:
> 
> I declared as follows in my class.  ui doesn't get set when called thru
> jaxrs:client but works fines otherwise.
> 
>         private UriInfo ui;
> 
> 	@Context
> 	public void setUriInfo(UriInfo ui) {
> 		this.ui = ui;
> 	}
> 
> Also, when a jaxrs server contains multiple providers for different custom
> types, it kind of ignores if there are is more than 1 type.  
> 
> for ex
> 
>         <jaxrs:server id="syncService" address="/sync">
>     	     <jaxrs:serviceBeans>
>       			<ref bean="syncServiceBean" />
>     	    </jaxrs:serviceBeans>
>     	<jaxrs:features>
>      		<cxf:logging/>
> 		</jaxrs:features>
> 		<jaxrs:providers>
> 			<ref bean="syncRequestReader"/>  <!-- for reading type SyncRequest-->
> 			<ref bean="downloadWriter"/>        <!-- for writing type
> DownloadSyncResponse -->
>                         <ref bean="profilePolicyReaderProvider"/> <!-- for
> reading ProfilePolicy type-->
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 
> It ignores profilePolicyReaderProvider for a CustomType ProfilePolicy and
> gives me an error that no message reader is found.  This limits the
> ability for an endpoint to read/write different custom types.
> 
> Yeah.. I have to check out continuations.   
> 
> Version: 2.2.3     Project work started from 2.1.x 
> 
> 
> Sergey Beryozkin-2 wrote:
>> 
>> 
>>>
>>> No, UriInfo was not set and was giving null pointer .. So I had to check
>>> Null
>>> Pointer before I used it
>> 
>> I'd really appreciate if you could give more infor about it (send me some
>> code please showing how UriInfo is declared, is it 
>> injected as a filed, etc). I have a WebClient test which uses
>> XSLTJaxbProvider on the inbound path, as a reader and it can get 
>> access to an injected UriInfo (though through a MessageContext). May be I
>> need to add another test with a jaxrs:client being 
>> involved...
>> By the way, what CXF version you're using ?
>> 
>> 
>>>
>>> I was under the assumption that ClientAPI uses colocation .. may be not
>>> yet.
>>> But for intra service messaging we definitely want colocation rather
>>> than go
>>> down the tcp stack.
>> 
>> sure...
>> 
>>>
>>> Also, can you please comment on the other question I had in the same
>>> thread.
>> 
>> about performance ? I guess the fact that jaxrs:clients use TCP affects
>> the performance a bit...
>> By the way, perhaps it's on overkill for your case, but have you thought
>> about using continuations in your service code ?
>> 
>> cheers, Sergey
>> 
>>>
>>> Thanks a lot for the quick response
>>>
>>> rkam
>>>
>>>
>>>
>>> Sergey Beryozkin-2 wrote:
>>>>
>>>> Hi
>>>>
>>>>
>>>>>
>>>>> jaxrs:client solution that you have provided worked perfectly fine.
>>>>
>>>> great...
>>>>
>>>>> I had to do a NP check on the UriInfo
>>>>
>>>> can you give me some more info please ? Is it not injected into your
>>>> custom reader when the jaxrs client starts processing the
>>>> response ?
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>> Now, I get the colocation performance benefit.
>>>>
>>>> Unfortunately not, not yet... I think it still goes over HTTP at the
>>>> moment - one of the tasks for 2.3 is to support a local
>>>> transport for JAXRS as well
>>>>
>>>> cheers, Sergey
>>>>
>>>>>
>>>>> rkam
>>>>> -- 
>>>>> View this message in context:
>>>>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25928219.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25932338.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by rkam <ra...@gmail.com>.
I declared as follows in my class.  ui doesn't get set when called thru
jaxrs:client but works fines otherwise.

        private UriInfo ui;

	@Context
	public void setUriInfo(UriInfo ui) {
		this.ui = ui;
	}

Also, when a jaxrs server contains multiple providers for different custom
types, it kind of ignores if there are is more than 1 type.  

for ex

        <jaxrs:server id="syncService" address="/sync">
    	     <jaxrs:serviceBeans>
      			<ref bean="syncServiceBean" />
    	    </jaxrs:serviceBeans>
    	<jaxrs:features>
     		<cxf:logging/>
		</jaxrs:features>
		<jaxrs:providers>
			<ref bean="syncRequestReader"/>  <!-- for reading type SyncRequest-->
			<ref bean="downloadWriter"/>        <!-- for writing type
DownloadSyncResponse -->
                        <ref bean="profilePolicyReaderProvider"/> <!-- for
reading ProfilePolicy type-->
		</jaxrs:providers>
	</jaxrs:server>

It ignores profilePolicyReaderProvider for a CustomType ProfilePolicy and
gives me an error that no message reader is found.  This limits the ability
for an endpoint to read/write different custom types.

Yeah.. I have to check out continuations.   

Version: 2.2.3     Project work started from 2.1.x 


Sergey Beryozkin-2 wrote:
> 
> 
>>
>> No, UriInfo was not set and was giving null pointer .. So I had to check
>> Null
>> Pointer before I used it
> 
> I'd really appreciate if you could give more infor about it (send me some
> code please showing how UriInfo is declared, is it 
> injected as a filed, etc). I have a WebClient test which uses
> XSLTJaxbProvider on the inbound path, as a reader and it can get 
> access to an injected UriInfo (though through a MessageContext). May be I
> need to add another test with a jaxrs:client being 
> involved...
> By the way, what CXF version you're using ?
> 
> 
>>
>> I was under the assumption that ClientAPI uses colocation .. may be not
>> yet.
>> But for intra service messaging we definitely want colocation rather than
>> go
>> down the tcp stack.
> 
> sure...
> 
>>
>> Also, can you please comment on the other question I had in the same
>> thread.
> 
> about performance ? I guess the fact that jaxrs:clients use TCP affects
> the performance a bit...
> By the way, perhaps it's on overkill for your case, but have you thought
> about using continuations in your service code ?
> 
> cheers, Sergey
> 
>>
>> Thanks a lot for the quick response
>>
>> rkam
>>
>>
>>
>> Sergey Beryozkin-2 wrote:
>>>
>>> Hi
>>>
>>>
>>>>
>>>> jaxrs:client solution that you have provided worked perfectly fine.
>>>
>>> great...
>>>
>>>> I had to do a NP check on the UriInfo
>>>
>>> can you give me some more info please ? Is it not injected into your
>>> custom reader when the jaxrs client starts processing the
>>> response ?
>>>
>>>
>>>
>>>
>>>>
>>>> Now, I get the colocation performance benefit.
>>>
>>> Unfortunately not, not yet... I think it still goes over HTTP at the
>>> moment - one of the tasks for 2.3 is to support a local
>>> transport for JAXRS as well
>>>
>>> cheers, Sergey
>>>
>>>>
>>>> rkam
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25928219.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25928772.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by Sergey Beryozkin <sb...@progress.com>.
>
> No, UriInfo was not set and was giving null pointer .. So I had to check Null
> Pointer before I used it

I'd really appreciate if you could give more infor about it (send me some code please showing how UriInfo is declared, is it 
injected as a filed, etc). I have a WebClient test which uses XSLTJaxbProvider on the inbound path, as a reader and it can get 
access to an injected UriInfo (though through a MessageContext). May be I need to add another test with a jaxrs:client being 
involved...
By the way, what CXF version you're using ?


>
> I was under the assumption that ClientAPI uses colocation .. may be not yet.
> But for intra service messaging we definitely want colocation rather than go
> down the tcp stack.

sure...

>
> Also, can you please comment on the other question I had in the same thread.

about performance ? I guess the fact that jaxrs:clients use TCP affects the performance a bit...
By the way, perhaps it's on overkill for your case, but have you thought about using continuations in your service code ?

cheers, Sergey

>
> Thanks a lot for the quick response
>
> rkam
>
>
>
> Sergey Beryozkin-2 wrote:
>>
>> Hi
>>
>>
>>>
>>> jaxrs:client solution that you have provided worked perfectly fine.
>>
>> great...
>>
>>> I had to do a NP check on the UriInfo
>>
>> can you give me some more info please ? Is it not injected into your
>> custom reader when the jaxrs client starts processing the
>> response ?
>>
>>
>>
>>
>>>
>>> Now, I get the colocation performance benefit.
>>
>> Unfortunately not, not yet... I think it still goes over HTTP at the
>> moment - one of the tasks for 2.3 is to support a local
>> transport for JAXRS as well
>>
>> cheers, Sergey
>>
>>>
>>> rkam
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25928219.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 


Re: Multiple Custom Providers

Posted by rkam <ra...@gmail.com>.
No, UriInfo was not set and was giving null pointer .. So I had to check Null
Pointer before I used it

I was under the assumption that ClientAPI uses colocation .. may be not yet. 
But for intra service messaging we definitely want colocation rather than go
down the tcp stack.  

Also, can you please comment on the other question I had in the same thread.

Thanks a lot for the quick response

rkam



Sergey Beryozkin-2 wrote:
> 
> Hi
> 
> 
>>
>> jaxrs:client solution that you have provided worked perfectly fine.
> 
> great...
> 
>> I had to do a NP check on the UriInfo
> 
> can you give me some more info please ? Is it not injected into your
> custom reader when the jaxrs client starts processing the 
> response ?
> 
> 
> 
> 
>>
>> Now, I get the colocation performance benefit.
> 
> Unfortunately not, not yet... I think it still goes over HTTP at the
> moment - one of the tasks for 2.3 is to support a local
> transport for JAXRS as well
> 
> cheers, Sergey
> 
>>
>> rkam
>> -- 
>> View this message in context:
>> http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25928219.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi


>
> jaxrs:client solution that you have provided worked perfectly fine.

great...

> I had to do a NP check on the UriInfo

can you give me some more info please ? Is it not injected into your custom reader when the jaxrs client starts processing the 
response ?


>
> Now, I get the colocation performance benefit.

Unfortunately not, not yet... I think it still goes over HTTP at the moment - one of the tasks for 2.3 is to support a local
transport for JAXRS as well

cheers, Sergey

>
> rkam
> -- 
> View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: Multiple Custom Providers

Posted by rkam <ra...@gmail.com>.
jaxrs:client solution that you have provided worked perfectly fine.  
I had to do a NP check on the UriInfo 

Now, I get the colocation performance benefit.

rkam
-- 
View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25926686.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Multiple Custom Providers

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

> But When Sync Service uses PolicyService using the Client API, I am getting
> the following error even though I am registering reader within the sync
> service.
>
> SEVERE: .No message body reader found for class : class
> biz.neustar.panjika.policy.dto.ProfilePolicy, ContentType : {1}.

I'll fiix the issue with {1}...(it might've been fixed in 2.2.4 though).
The client which is created inside "syncService" does not get the providers which have been registered for
the syncService itself...I didn't want to do it to avoid some unexpected clashes, ex, syncService is using a customized JAXBProvider 
which makes sense in the scope of interactions between "syncService" clients and the "syncService" itself but which would break the 
outbound XML requests "syncService" might be doing while processing some calls...

I think I might add a jaxrs property to jaxrs:server, something like 'inheritProviders' which will let clients just to use providers 
utilized by the endpoint itself...

In meantime, please use jaxrs:client, ex :

<jaxrs:client id="policyClient"

address=http://localhost:9092/policy

serviceClass="MobilePhonePolicyQueryService">

<jaxrs:providers>
   <ref bean="profilePolicyReaderProvider"/>
</jaxrs:providers>


<jaxrs:client>


and have this code in the syncService impl :

@Resource(name = "policyClient")

private MobilePhonePolicyQueryService webClient;


Unfortunately, this requires you to know the MobilePhonePolicyQueryService address in advance, if it's feasible then it will work, 
otherwise a createdFromAPI = true attribute which actually works for jaxws:client(s) would be the best fit, but I haven't even tried 
it with jaxrs:client yet. So I have two more tasks now to deal with (inheritProviders property, createdFromAPI = true support)

let me know how it goes please
Sergey


>
> I have two services registered.
>
>
> <jaxrs:server id="syncService" address="/sync">
>    <jaxrs:serviceBeans>
>      <ref bean="syncServiceBean" />
>    </jaxrs:serviceBeans>
> <jaxrs:providers>
> <ref bean="syncRequestReader"/>
> <ref bean="downloadWriter"/>
> <ref bean="profilePolicyReaderProvider"/>
> </jaxrs:providers>
> </jaxrs:server>
>
> <jaxrs:server id="policyService" address="/policy">
>    <jaxrs:serviceBeans>
>      <ref bean="mobilePhonePolicyQueryService"/>
>    </jaxrs:serviceBeans>
> <jaxrs:providers>
> <ref bean="profilePolicyReaderProvider"/>
> <ref bean="profilePolicyWriterProvider"/>
> </jaxrs:providers>
> </jaxrs:server>
>
>         <bean id="syncRequestReader"
> class="biz.neustar.panjika.server.dto.SyncRequestReaderProvider"/>
>
>  <bean id="downloadWriter"
> class="biz.neustar.panjika.server.dto.DownloadWriterProvider"/>
>
>         <bean id="profilePolicyReaderProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyReaderProvider"/>
>  <bean id="profilePolicyWriterProvider"
> class="biz.neustar.panjika.policy.dto.ProfilePolicyWriterProvider"/>
>
>
> Sync Service is using a reader/writer provider and while PolicyService has
> its own two providers. Both work independently fine.
>
> But When Sync Service uses PolicyService using the Client API, I am getting
> the following error even though I am registering reader within the sync
> service.
>
> SEVERE: .No message body reader found for class : class
> biz.neustar.panjika.policy.dto.ProfilePolicy, ContentType : {1}.
> javax.ws.rs.WebApplicationException
> at
> org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:450)
> at
> org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:410)
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:422)
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:404)
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:163)
> at
> org.apache.cxf.common.util.CglibProxyHelper$1.intercept(CglibProxyHelper.java:66)
> at
> biz.neustar.panjika.policy.MobilePhonePolicyQueryService$$EnhancerByCGLIB$$ad5a408f.isPublished(<generated>)
>
> Any help is greatly appreciated.
>
> Thanks
> rkam
>
>
> -- 
> View this message in context: http://www.nabble.com/Multiple-Custom-Providers-tp25916823p25916823.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>