You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by HamletDRC <ha...@gmail.com> on 2009/09/28 18:56:11 UTC

Can't Proxy Service classes

I'm trying to create a standard Java 5 Proxy of my service classes and can't
get it to work. 

I've tried several approaches, does anyone have any insight about what is
going wrong? 

In both approaches, I'm creating a standard Java 5 Proxy out of the service
class and an InvocationHandler. To make this easy in the Spring config I
wrote a little type safe Proxy utility: 

public class ProxyUtils {
	public static <T> T makeProxy(InvocationHandler handler, Class<T> clazz) {
		return clazz.cast(
			Proxy.newProxyInstance(
				clazz.getClassLoader(),
				new Class[]{clazz},
				handler)
		);
	}
Also, in both approaches there are "SystemParameterService" and
"SystemParameterServiceImpl" as the service class. 
 
Approach #1 - Define an "implementorClass" on jaxws:endpoint - Results in
error "java.lang.IllegalArgumentException: object is not an instance of
declaring class" error. 

I defined my endpoint with an implementorClass like so: 
	<jaxws:endpoint id="systemParameter"
					implementor="#systemParameterService"
					implementorClass="vue.tcsm.services.SystemParameterService"
					address="/SystemParameterService">
	</jaxws:endpoint>

Then I just created a proxy of the service class: 
	<bean id="systemParameterService" scope="prototype"
class="vue.tcsm.services.ProxyUtils" factory-method="makeProxy">
		<constructor-arg>
			<bean class="vue.tcsm.services.VueSystemAppUserBeforeAdvice"
scope="prototype">
				<constructor-arg>
					<bean class="vue.tcsm.services.SystemParameterServiceImpl"
scope="prototype"/>
				</constructor-arg>
			</bean>
		</constructor-arg>
		<constructor-arg value="vue.tcsm.services.SystemParameterService" />
	</bean>

The Exception comes out of JAXWSMethodInvoker and kind of makes sense. The
service class is a Proxy and not a SystemParameterService, so I understand
the message. Is there a way to make this approach work? 

Approach #2 - Don't Define an "implementorClass" - results in
"org.apache.cxf.interceptor.Fault: Message part {http://cxf.example/}xxx was
not recognized.  (Does it exist in service WSDL?)"

In this approach I simply dropped off the "implementorClass" attribute. This
results in the WSDL not being generated correctly and this exception. 


Is there a way to use Java 5 Proxy with CXF? 

Thanks, 




-----
--
Hamlet D'Arcy

-- 
View this message in context: http://www.nabble.com/Can%27t-Proxy-Service-classes-tp25648984p25648984.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Can't Proxy Service classes

Posted by HamletDRC <ha...@gmail.com>.
OK, I got a Java 5 Proxy to be invoked thru CXF. I had to: 

* Declare an interface for the service class
* Annotate interface with @WebService
* Annotate interface method with @WebMethod, @WebResult, and all the @Web
Param annotations
* Declare a service class that implements the interface
* Annotate class with @WebService. Set the attributes for serviceName and
endpointInterface
* there is _no_ need to add @WebMethod, @WebResult, or @WebParam to the
class
* In the Spring XML: Proxy your class

Thanks, 
Hamlet



dkulp wrote:
> 
> 
> Any chance you could take a simple "hello world" sample or something and 
> create a small test project that completely shows everything?   Its
> definitely 
> easier to see what is going on if I can run it in the debugger.
> 
> Dan
> 
> 
> On Mon September 28 2009 2:16:25 pm HamletDRC wrote:
>> Here is what I added to make Tomcat start up properly:
>> 
>> The SystemParameterService interface is marked with @WebService
>> The SystemParameterServiceImpl class is marked with:
>>   @WebService(serviceName = "SystemParameterService", endpointInterface =
>> "vue.tcsm.services.SystemParameterService")
>>   The class methods are given the proper @WebMethod annotations too.
>> 
>> The WSDL generates now and tomcat starts with no errors. Progress.
>> 
>> But none of the endpoints can be invoked. I get the same old exception:
>> 
>> org.apache.cxf.interceptor.Fault: object is not an instance of declaring
>> class while invoking public void
>> vue.tcsm.services.SiteAvailabilityServiceImpl.createAvailability(vue.tcsm.d
>> to.TestCenterDTO) throws vue.tcsm.failures.ValidationFault with params
>>  [null].
>> 
>> It is thrown from the line :
>>   CastUtils.cast((List)super.invoke(exchange, serviceObject, m, params));
>> in org.apache.cxf.jaxws.JAXWSMethodInvoker
>> 
>> 
>> Any ideas?
>> 
>> --
>> Hamlet
>> 
>> dkulp wrote:
>> > I believe implementorClass  needs to point to the actual Impl class
>> which
>> > would then have the proper @WebService annotation that would have the
>> > endpointInterface attribute defined on it.
>> >
>> > Dan
>> >
>> > On Mon September 28 2009 12:56:11 pm HamletDRC wrote:
>> >> I'm trying to create a standard Java 5 Proxy of my service classes and
>> >>  can't get it to work.
>> >>
>> >> I've tried several approaches, does anyone have any insight about what
>> >> is going wrong?
>> >>
>> >> In both approaches, I'm creating a standard Java 5 Proxy out of the
>> >> service
>> >> class and an InvocationHandler. To make this easy in the Spring config
>> I
>> >> wrote a little type safe Proxy utility:
>> >>
>> >> public class ProxyUtils {
>> >> 	public static <T> T makeProxy(InvocationHandler handler, Class<T>
>> >> clazz) {
>> >> 		return clazz.cast(
>> >> 			Proxy.newProxyInstance(
>> >> 				clazz.getClassLoader(),
>> >> 				new Class[]{clazz},
>> >> 				handler)
>> >> 		);
>> >> 	}
>> >> Also, in both approaches there are "SystemParameterService" and
>> >> "SystemParameterServiceImpl" as the service class.
>> >>
>> >> Approach #1 - Define an "implementorClass" on jaxws:endpoint - Results
>> >> in error "java.lang.IllegalArgumentException: object is not an
>> instance
>> >> of declaring class" error.
>> >>
>> >> I defined my endpoint with an implementorClass like so:
>> >> 	<jaxws:endpoint id="systemParameter"
>> >> 					implementor="#systemParameterService"
>> >> 					implementorClass="vue.tcsm.services.SystemParameterService"
>> >> 					address="/SystemParameterService">
>> >> 	</jaxws:endpoint>
>> >>
>> >> Then I just created a proxy of the service class:
>> >> 	<bean id="systemParameterService" scope="prototype"
>> >> class="vue.tcsm.services.ProxyUtils" factory-method="makeProxy">
>> >> 		<constructor-arg>
>> >> 			<bean class="vue.tcsm.services.VueSystemAppUserBeforeAdvice"
>> >> scope="prototype">
>> >> 				<constructor-arg>
>> >> 					<bean class="vue.tcsm.services.SystemParameterServiceImpl"
>> >> scope="prototype"/>
>> >> 				</constructor-arg>
>> >> 			</bean>
>> >> 		</constructor-arg>
>> >> 		<constructor-arg value="vue.tcsm.services.SystemParameterService" />
>> >> 	</bean>
>> >>
>> >> The Exception comes out of JAXWSMethodInvoker and kind of makes sense.
>> >> The
>> >> service class is a Proxy and not a SystemParameterService, so I
>> >> understand
>> >> the message. Is there a way to make this approach work?
>> >>
>> >> Approach #2 - Don't Define an "implementorClass" - results in
>> >> "org.apache.cxf.interceptor.Fault: Message part
>> {http://cxf.example/}xxx
>> >>  was not recognized.  (Does it exist in service WSDL?)"
>> >>
>> >> In this approach I simply dropped off the "implementorClass"
>> attribute.
>> >>  This results in the WSDL not being generated correctly and this
>> >> exception.
>> >>
>> >>
>> >> Is there a way to use Java 5 Proxy with CXF?
>> >>
>> >> Thanks,
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> --
>> >> Hamlet D'Arcy
>> 
>> -----
>> --
>> Hamlet D'Arcy
>> 
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 


-----
--
Hamlet D'Arcy

-- 
View this message in context: http://www.nabble.com/Can%27t-Proxy-Service-classes-tp25648984p25653674.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Can't Proxy Service classes

Posted by Daniel Kulp <dk...@apache.org>.
Any chance you could take a simple "hello world" sample or something and 
create a small test project that completely shows everything?   Its definitely 
easier to see what is going on if I can run it in the debugger.

Dan


On Mon September 28 2009 2:16:25 pm HamletDRC wrote:
> Here is what I added to make Tomcat start up properly:
> 
> The SystemParameterService interface is marked with @WebService
> The SystemParameterServiceImpl class is marked with:
>   @WebService(serviceName = "SystemParameterService", endpointInterface =
> "vue.tcsm.services.SystemParameterService")
>   The class methods are given the proper @WebMethod annotations too.
> 
> The WSDL generates now and tomcat starts with no errors. Progress.
> 
> But none of the endpoints can be invoked. I get the same old exception:
> 
> org.apache.cxf.interceptor.Fault: object is not an instance of declaring
> class while invoking public void
> vue.tcsm.services.SiteAvailabilityServiceImpl.createAvailability(vue.tcsm.d
> to.TestCenterDTO) throws vue.tcsm.failures.ValidationFault with params
>  [null].
> 
> It is thrown from the line :
>   CastUtils.cast((List)super.invoke(exchange, serviceObject, m, params));
> in org.apache.cxf.jaxws.JAXWSMethodInvoker
> 
> 
> Any ideas?
> 
> --
> Hamlet
> 
> dkulp wrote:
> > I believe implementorClass  needs to point to the actual Impl class which
> > would then have the proper @WebService annotation that would have the
> > endpointInterface attribute defined on it.
> >
> > Dan
> >
> > On Mon September 28 2009 12:56:11 pm HamletDRC wrote:
> >> I'm trying to create a standard Java 5 Proxy of my service classes and
> >>  can't get it to work.
> >>
> >> I've tried several approaches, does anyone have any insight about what
> >> is going wrong?
> >>
> >> In both approaches, I'm creating a standard Java 5 Proxy out of the
> >> service
> >> class and an InvocationHandler. To make this easy in the Spring config I
> >> wrote a little type safe Proxy utility:
> >>
> >> public class ProxyUtils {
> >> 	public static <T> T makeProxy(InvocationHandler handler, Class<T>
> >> clazz) {
> >> 		return clazz.cast(
> >> 			Proxy.newProxyInstance(
> >> 				clazz.getClassLoader(),
> >> 				new Class[]{clazz},
> >> 				handler)
> >> 		);
> >> 	}
> >> Also, in both approaches there are "SystemParameterService" and
> >> "SystemParameterServiceImpl" as the service class.
> >>
> >> Approach #1 - Define an "implementorClass" on jaxws:endpoint - Results
> >> in error "java.lang.IllegalArgumentException: object is not an instance
> >> of declaring class" error.
> >>
> >> I defined my endpoint with an implementorClass like so:
> >> 	<jaxws:endpoint id="systemParameter"
> >> 					implementor="#systemParameterService"
> >> 					implementorClass="vue.tcsm.services.SystemParameterService"
> >> 					address="/SystemParameterService">
> >> 	</jaxws:endpoint>
> >>
> >> Then I just created a proxy of the service class:
> >> 	<bean id="systemParameterService" scope="prototype"
> >> class="vue.tcsm.services.ProxyUtils" factory-method="makeProxy">
> >> 		<constructor-arg>
> >> 			<bean class="vue.tcsm.services.VueSystemAppUserBeforeAdvice"
> >> scope="prototype">
> >> 				<constructor-arg>
> >> 					<bean class="vue.tcsm.services.SystemParameterServiceImpl"
> >> scope="prototype"/>
> >> 				</constructor-arg>
> >> 			</bean>
> >> 		</constructor-arg>
> >> 		<constructor-arg value="vue.tcsm.services.SystemParameterService" />
> >> 	</bean>
> >>
> >> The Exception comes out of JAXWSMethodInvoker and kind of makes sense.
> >> The
> >> service class is a Proxy and not a SystemParameterService, so I
> >> understand
> >> the message. Is there a way to make this approach work?
> >>
> >> Approach #2 - Don't Define an "implementorClass" - results in
> >> "org.apache.cxf.interceptor.Fault: Message part {http://cxf.example/}xxx
> >>  was not recognized.  (Does it exist in service WSDL?)"
> >>
> >> In this approach I simply dropped off the "implementorClass" attribute.
> >>  This results in the WSDL not being generated correctly and this
> >> exception.
> >>
> >>
> >> Is there a way to use Java 5 Proxy with CXF?
> >>
> >> Thanks,
> >>
> >>
> >>
> >>
> >> -----
> >> --
> >> Hamlet D'Arcy
> 
> -----
> --
> Hamlet D'Arcy
> 

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

Re: Can't Proxy Service classes

Posted by HamletDRC <ha...@gmail.com>.
Here is what I added to make Tomcat start up properly: 

The SystemParameterService interface is marked with @WebService
The SystemParameterServiceImpl class is marked with: 
  @WebService(serviceName = "SystemParameterService", endpointInterface =
"vue.tcsm.services.SystemParameterService")
  The class methods are given the proper @WebMethod annotations too. 

The WSDL generates now and tomcat starts with no errors. Progress. 

But none of the endpoints can be invoked. I get the same old exception: 

org.apache.cxf.interceptor.Fault: object is not an instance of declaring
class while invoking public void
vue.tcsm.services.SiteAvailabilityServiceImpl.createAvailability(vue.tcsm.dto.TestCenterDTO)
throws vue.tcsm.failures.ValidationFault with params [null].

It is thrown from the line : 
  CastUtils.cast((List)super.invoke(exchange, serviceObject, m, params));
in org.apache.cxf.jaxws.JAXWSMethodInvoker


Any ideas? 

--
Hamlet





dkulp wrote:
> 
> 
> I believe implementorClass  needs to point to the actual Impl class which 
> would then have the proper @WebService annotation that would have the 
> endpointInterface attribute defined on it.
> 
> Dan
> 
> On Mon September 28 2009 12:56:11 pm HamletDRC wrote:
>> I'm trying to create a standard Java 5 Proxy of my service classes and
>>  can't get it to work.
>> 
>> I've tried several approaches, does anyone have any insight about what is
>> going wrong?
>> 
>> In both approaches, I'm creating a standard Java 5 Proxy out of the
>> service
>> class and an InvocationHandler. To make this easy in the Spring config I
>> wrote a little type safe Proxy utility:
>> 
>> public class ProxyUtils {
>> 	public static <T> T makeProxy(InvocationHandler handler, Class<T> clazz)
>> {
>> 		return clazz.cast(
>> 			Proxy.newProxyInstance(
>> 				clazz.getClassLoader(),
>> 				new Class[]{clazz},
>> 				handler)
>> 		);
>> 	}
>> Also, in both approaches there are "SystemParameterService" and
>> "SystemParameterServiceImpl" as the service class.
>> 
>> Approach #1 - Define an "implementorClass" on jaxws:endpoint - Results in
>> error "java.lang.IllegalArgumentException: object is not an instance of
>> declaring class" error.
>> 
>> I defined my endpoint with an implementorClass like so:
>> 	<jaxws:endpoint id="systemParameter"
>> 					implementor="#systemParameterService"
>> 					implementorClass="vue.tcsm.services.SystemParameterService"
>> 					address="/SystemParameterService">
>> 	</jaxws:endpoint>
>> 
>> Then I just created a proxy of the service class:
>> 	<bean id="systemParameterService" scope="prototype"
>> class="vue.tcsm.services.ProxyUtils" factory-method="makeProxy">
>> 		<constructor-arg>
>> 			<bean class="vue.tcsm.services.VueSystemAppUserBeforeAdvice"
>> scope="prototype">
>> 				<constructor-arg>
>> 					<bean class="vue.tcsm.services.SystemParameterServiceImpl"
>> scope="prototype"/>
>> 				</constructor-arg>
>> 			</bean>
>> 		</constructor-arg>
>> 		<constructor-arg value="vue.tcsm.services.SystemParameterService" />
>> 	</bean>
>> 
>> The Exception comes out of JAXWSMethodInvoker and kind of makes sense.
>> The
>> service class is a Proxy and not a SystemParameterService, so I
>> understand
>> the message. Is there a way to make this approach work?
>> 
>> Approach #2 - Don't Define an "implementorClass" - results in
>> "org.apache.cxf.interceptor.Fault: Message part {http://cxf.example/}xxx
>>  was not recognized.  (Does it exist in service WSDL?)"
>> 
>> In this approach I simply dropped off the "implementorClass" attribute.
>>  This results in the WSDL not being generated correctly and this
>> exception.
>> 
>> 
>> Is there a way to use Java 5 Proxy with CXF?
>> 
>> Thanks,
>> 
>> 
>> 
>> 
>> -----
>> --
>> Hamlet D'Arcy
>> 
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 


-----
--
Hamlet D'Arcy

-- 
View this message in context: http://www.nabble.com/Can%27t-Proxy-Service-classes-tp25648984p25650292.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Can't Proxy Service classes

Posted by Daniel Kulp <dk...@apache.org>.
I believe implementorClass  needs to point to the actual Impl class which 
would then have the proper @WebService annotation that would have the 
endpointInterface attribute defined on it.

Dan

On Mon September 28 2009 12:56:11 pm HamletDRC wrote:
> I'm trying to create a standard Java 5 Proxy of my service classes and
>  can't get it to work.
> 
> I've tried several approaches, does anyone have any insight about what is
> going wrong?
> 
> In both approaches, I'm creating a standard Java 5 Proxy out of the service
> class and an InvocationHandler. To make this easy in the Spring config I
> wrote a little type safe Proxy utility:
> 
> public class ProxyUtils {
> 	public static <T> T makeProxy(InvocationHandler handler, Class<T> clazz) {
> 		return clazz.cast(
> 			Proxy.newProxyInstance(
> 				clazz.getClassLoader(),
> 				new Class[]{clazz},
> 				handler)
> 		);
> 	}
> Also, in both approaches there are "SystemParameterService" and
> "SystemParameterServiceImpl" as the service class.
> 
> Approach #1 - Define an "implementorClass" on jaxws:endpoint - Results in
> error "java.lang.IllegalArgumentException: object is not an instance of
> declaring class" error.
> 
> I defined my endpoint with an implementorClass like so:
> 	<jaxws:endpoint id="systemParameter"
> 					implementor="#systemParameterService"
> 					implementorClass="vue.tcsm.services.SystemParameterService"
> 					address="/SystemParameterService">
> 	</jaxws:endpoint>
> 
> Then I just created a proxy of the service class:
> 	<bean id="systemParameterService" scope="prototype"
> class="vue.tcsm.services.ProxyUtils" factory-method="makeProxy">
> 		<constructor-arg>
> 			<bean class="vue.tcsm.services.VueSystemAppUserBeforeAdvice"
> scope="prototype">
> 				<constructor-arg>
> 					<bean class="vue.tcsm.services.SystemParameterServiceImpl"
> scope="prototype"/>
> 				</constructor-arg>
> 			</bean>
> 		</constructor-arg>
> 		<constructor-arg value="vue.tcsm.services.SystemParameterService" />
> 	</bean>
> 
> The Exception comes out of JAXWSMethodInvoker and kind of makes sense. The
> service class is a Proxy and not a SystemParameterService, so I understand
> the message. Is there a way to make this approach work?
> 
> Approach #2 - Don't Define an "implementorClass" - results in
> "org.apache.cxf.interceptor.Fault: Message part {http://cxf.example/}xxx
>  was not recognized.  (Does it exist in service WSDL?)"
> 
> In this approach I simply dropped off the "implementorClass" attribute.
>  This results in the WSDL not being generated correctly and this exception.
> 
> 
> Is there a way to use Java 5 Proxy with CXF?
> 
> Thanks,
> 
> 
> 
> 
> -----
> --
> Hamlet D'Arcy
> 

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