You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by nicolas de loof <ni...@gmail.com> on 2009/05/05 10:39:16 UTC

@Resource injection fails in 2.2.1

Hi
I'm using <jaxws:endpoint to expose my web services, generated using
wsdl2java :

  <jaxws:endpoint address="/consultation/1.0"
implementor="#consultationEndPoint"
wsdlLocation="wsdl/consultation_v1.0.wsdl"/>

  <bean id="consultationEndPoint" class="com.foo.ConsultationEndPoint" />


My EndPoint uses @Resource annotation to get Spring business-layer beans.
I get an error on CXF 2.2.1 :

Caused by: java.lang.IllegalArgumentException: Can not set
com.foo.ConsultationService field com.foo.ConsultationEndPoint.service to
$Proxy176
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)

The resource injector seems to use the proxy generated by <jaxws:endpoint>
for resource injection and not the implementor bean.


Nicolas

RE: @Resource injection fails in 2.2.1

Posted by Ron Grimes <rg...@sinclairoil.com>.
Are you sure that you are declaring the @Resource correctly in your
service class? The reason that I ask is I use the following with
success:

ApplicationContext.xml
	<bean	id="webServiceContextImpl"
	
class="org.apache.cxf.jaxws.context.WebServiceContextImpl">
	</bean>

Service class
	@Resource(name = "webServiceContextImpl")
	private WebServiceContext wsContext; 


So, I reference the @Resource by its bean id. I'm not sure, from the
error message that you attached, that you are referencing the bean id
name in the service class.

Ron


-----Original Message-----
From: Karthik Abram [mailto:karthik.abram@neovera.com] 
Sent: Tuesday, May 05, 2009 11:23 AM
To: users@cxf.apache.org
Subject: RE: @Resource injection fails in 2.2.1

Try the following:
Add <bean
class="org.springframework.context.annotation.CommonAnnotationBeanPostPr
oces
sor"/>


-----Original Message-----
From: nicolas de loof [mailto:nicolas.deloof@gmail.com]
Sent: Tuesday, May 05, 2009 4:39 AM
To: cxf-user@incubator.apache.org
Subject: @Resource injection fails in 2.2.1

Hi
I'm using <jaxws:endpoint to expose my web services, generated using
wsdl2java :

  <jaxws:endpoint address="/consultation/1.0"
implementor="#consultationEndPoint"
wsdlLocation="wsdl/consultation_v1.0.wsdl"/>

  <bean id="consultationEndPoint" class="com.foo.ConsultationEndPoint"
/>


My EndPoint uses @Resource annotation to get Spring business-layer
beans.
I get an error on CXF 2.2.1 :

Caused by: java.lang.IllegalArgumentException: Can not set
com.foo.ConsultationService field com.foo.ConsultationEndPoint.service
to
$Proxy176
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Uns
afeF
ieldAccessorImpl.java:146)

The resource injector seems to use the proxy generated by
<jaxws:endpoint> for resource injection and not the implementor bean.


Nicolas


RE: @Resource injection fails in 2.2.1

Posted by Karthik Abram <ka...@neovera.com>.
Try the following:
Add <bean
class="org.springframework.context.annotation.CommonAnnotationBeanPostProces
sor"/>


-----Original Message-----
From: nicolas de loof [mailto:nicolas.deloof@gmail.com] 
Sent: Tuesday, May 05, 2009 4:39 AM
To: cxf-user@incubator.apache.org
Subject: @Resource injection fails in 2.2.1

Hi
I'm using <jaxws:endpoint to expose my web services, generated using
wsdl2java :

  <jaxws:endpoint address="/consultation/1.0"
implementor="#consultationEndPoint"
wsdlLocation="wsdl/consultation_v1.0.wsdl"/>

  <bean id="consultationEndPoint" class="com.foo.ConsultationEndPoint" />


My EndPoint uses @Resource annotation to get Spring business-layer beans.
I get an error on CXF 2.2.1 :

Caused by: java.lang.IllegalArgumentException: Can not set
com.foo.ConsultationService field com.foo.ConsultationEndPoint.service to
$Proxy176
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeF
ieldAccessorImpl.java:146)

The resource injector seems to use the proxy generated by <jaxws:endpoint>
for resource injection and not the implementor bean.


Nicolas


Re: @Resource injection fails in 2.2.1

Posted by Daniel Kulp <dk...@apache.org>.
Well, not really a CXF bug as there really isn't anything we can do about it.  
(I think)

<jaxws:endpoint> doesn't create a proxy for anything.    It creates a concrete 
subclass of Endpoint.   If you are seeing for it, that is Spring's auto proxy 
stuff kicking in and doing some sort of wacky JDK5 proxy object wrapping.   


Dan


On Tue May 5 2009 2:04:33 pm nicolas de loof wrote:
> I allready have @Ressource annotation injection support in my
> spring-context (it is automatically enabled by <context:component-scan>)
>
> Moving the @Resource to a setter fix the issue (as only Spring will support
> this).
>
> Changing <aop:* and <tx:* to use proxy-target-class=true also fix this
> issue as another option.
>
> Anyway this sounds like a CXF bug to me, isn't it ?
>
> 2009/5/5 Karthik Abram <ka...@neovera.com>
>
> > Try the following:
> > Add <bean
> >
> > class="org.springframework.context.annotation.CommonAnnotationBeanPostPro
> >ces sor"/>
> >
> >
> > -----Original Message-----
> > From: nicolas de loof [mailto:nicolas.deloof@gmail.com]
> > Sent: Tuesday, May 05, 2009 4:39 AM
> > To: cxf-user@incubator.apache.org
> > Subject: @Resource injection fails in 2.2.1
> >
> > Hi
> > I'm using <jaxws:endpoint to expose my web services, generated using
> > wsdl2java :
> >
> >  <jaxws:endpoint address="/consultation/1.0"
> > implementor="#consultationEndPoint"
> > wsdlLocation="wsdl/consultation_v1.0.wsdl"/>
> >
> >  <bean id="consultationEndPoint" class="com.foo.ConsultationEndPoint" />
> >
> >
> > My EndPoint uses @Resource annotation to get Spring business-layer beans.
> > I get an error on CXF 2.2.1 :
> >
> > Caused by: java.lang.IllegalArgumentException: Can not set
> > com.foo.ConsultationService field com.foo.ConsultationEndPoint.service to
> > $Proxy176
> > at
> >
> > sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unsa
> >feF ieldAccessorImpl.java:146)
> >
> > The resource injector seems to use the proxy generated by
> > <jaxws:endpoint> for resource injection and not the implementor bean.
> >
> >
> > Nicolas

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: @Resource injection fails in 2.2.1

Posted by nicolas de loof <ni...@gmail.com>.
I allready have @Ressource annotation injection support in my spring-context
(it is automatically enabled by <context:component-scan>)

Moving the @Resource to a setter fix the issue (as only Spring will support
this).

Changing <aop:* and <tx:* to use proxy-target-class=true also fix this issue
as another option.

Anyway this sounds like a CXF bug to me, isn't it ?

2009/5/5 Karthik Abram <ka...@neovera.com>

> Try the following:
> Add <bean
>
> class="org.springframework.context.annotation.CommonAnnotationBeanPostProces
> sor"/>
>
>
> -----Original Message-----
> From: nicolas de loof [mailto:nicolas.deloof@gmail.com]
> Sent: Tuesday, May 05, 2009 4:39 AM
> To: cxf-user@incubator.apache.org
> Subject: @Resource injection fails in 2.2.1
>
> Hi
> I'm using <jaxws:endpoint to expose my web services, generated using
> wsdl2java :
>
>  <jaxws:endpoint address="/consultation/1.0"
> implementor="#consultationEndPoint"
> wsdlLocation="wsdl/consultation_v1.0.wsdl"/>
>
>  <bean id="consultationEndPoint" class="com.foo.ConsultationEndPoint" />
>
>
> My EndPoint uses @Resource annotation to get Spring business-layer beans.
> I get an error on CXF 2.2.1 :
>
> Caused by: java.lang.IllegalArgumentException: Can not set
> com.foo.ConsultationService field com.foo.ConsultationEndPoint.service to
> $Proxy176
> at
>
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeF
> ieldAccessorImpl.java:146)
>
> The resource injector seems to use the proxy generated by <jaxws:endpoint>
> for resource injection and not the implementor bean.
>
>
> Nicolas
>
>