You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by MartyH <ma...@singularity.co.uk> on 2007/07/25 14:24:08 UTC
beginner q: classnotfoundexception using DynamicClientFactory
Hi folks,
Having some diffs with the DynamicClientFactory.
On following the example like so:
[code]
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
DynamicClientFactory dcf = DynamicClientFactory.newInstance();
Client client =
dcf.createClient("http://www.webservicex.net/CurrencyConvertor.asmx?wsdl",
classLoader);
Object rate =
classLoader.loadClass("net.webservicex.ConversionRate").newInstance();
Method m1 = rate.getClass().getMethod("setFromCurrency",
String.class);
Method m2 = rate.getClass().getMethod("setToCurrency",
String.class);
m1.invoke(rate, "GBP");
m2.invoke(rate, "USD");
Object result = client.invoke("ConversionRate", rate);
System.out.println("result=" + result);
[/code]
I get a classnotfoundexception on the loadClass bit to create the object.
CXF seems to be creating the necessary objects:
[code]
25-Jul-2007 12:10:34 org.apache.cxf.endpoint.dynamic.DynamicClientFactory
outputDebug
INFO: Created classes: net.webservicex.ConversionRate,
net.webservicex.ConversionRateResponse, net.webservicex.Currency,
net.webservicex.ObjectFactory
[/code]
but they don't seem to be available in the classloader.
Any thoughts?
thanks,
Marty
--
View this message in context: http://www.nabble.com/beginner-q%3A-classnotfoundexception-using-DynamicClientFactory-tf4141887.html#a11781608
Sent from the cxf-user mailing list archive at Nabble.com.
RE: beginner q: classnotfoundexception using DynamicClientFactory
Posted by MartyH <ma...@singularity.co.uk>.
thanks a lot my man! :-)
--
View this message in context: http://www.nabble.com/beginner-q%3A-classnotfoundexception-using-DynamicClientFactory-tf4141887.html#a11783635
Sent from the cxf-user mailing list archive at Nabble.com.
RE: beginner q: classnotfoundexception using DynamicClientFactory
Posted by "Jiang, Ning (Willem)" <Ni...@iona.com>.
Hi,
I just went through the DynamicClientFactory code, and found your code got class loader a little earlier.
When the DynamicClientFactory create the client , it will setup the classpath to load the generated class.
You just need to use the thread's ContextClassLoader after the dcf.createClient to load the jaxb class.
The codes could be:
[code]
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
DynamicClientFactory dcf = DynamicClientFactory.newInstance();
Client client =
dcf.createClient("http://www.webservicex.net/CurrencyConvertor.asmx?wsdl",
classLoader);
Object rate =
Thread.currentThread().getContextClassLoader().loadClass("net.webservicex.ConversionRate").newInstance();
Method m1 = rate.getClass().getMethod("setFromCurrency",
String.class);
Method m2 = rate.getClass().getMethod("setToCurrency",
String.class);
m1.invoke(rate, "GBP");
m2.invoke(rate, "USD");
Object result = client.invoke("ConversionRate", rate);
System.out.println("result=" + result);
[/code]
Willem.
-----Original Message-----
From: MartyH [mailto:martin.henderson@singularity.co.uk]
Sent: Wed 7/25/2007 20:24
To: cxf-user@incubator.apache.org
Subject: beginner q: classnotfoundexception using DynamicClientFactory
Hi folks,
Having some diffs with the DynamicClientFactory.
On following the example like so:
[code]
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
DynamicClientFactory dcf = DynamicClientFactory.newInstance();
Client client =
dcf.createClient("http://www.webservicex.net/CurrencyConvertor.asmx?wsdl",
classLoader);
Object rate =
classLoader.loadClass("net.webservicex.ConversionRate").newInstance();
Method m1 = rate.getClass().getMethod("setFromCurrency",
String.class);
Method m2 = rate.getClass().getMethod("setToCurrency",
String.class);
m1.invoke(rate, "GBP");
m2.invoke(rate, "USD");
Object result = client.invoke("ConversionRate", rate);
System.out.println("result=" + result);
[/code]
I get a classnotfoundexception on the loadClass bit to create the object.
CXF seems to be creating the necessary objects:
[code]
25-Jul-2007 12:10:34 org.apache.cxf.endpoint.dynamic.DynamicClientFactory
outputDebug
INFO: Created classes: net.webservicex.ConversionRate,
net.webservicex.ConversionRateResponse, net.webservicex.Currency,
net.webservicex.ObjectFactory
[/code]
but they don't seem to be available in the classloader.
Any thoughts?
thanks,
Marty
--
View this message in context: http://www.nabble.com/beginner-q%3A-classnotfoundexception-using-DynamicClientFactory-tf4141887.html#a11781608
Sent from the cxf-user mailing list archive at Nabble.com.