

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
3 messages in org.apache.cxf.userRE: beginner q: classnotfoundexceptio...| From | Sent On | Attachments |
|---|---|---|
| MartyH | Jul 25, 2007 5:23 am | |
| Jiang, Ning (Willem) | Jul 25, 2007 7:04 am | |
| MartyH | Jul 25, 2007 7:25 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | RE: beginner q: classnotfoundexception using DynamicClientFactory | Actions... |
|---|---|---|
| From: | Jiang, Ning (Willem) (Ning...@iona.com) | |
| Date: | Jul 25, 2007 7:04:43 am | |
| List: | org.apache.cxf.user | |
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:mart...@singularity.co.uk] Sent: Wed 7/25/2007 20:24 To: cxf-...@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.







