cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Not able to compile wsdl file using JaxWsDynamicClientFactory
Date Fri, 24 Sep 2010 14:08:11 GMT
On Thursday 23 September 2010 10:59:37 am xiaotao183 wrote:
> Hi all,
> 
> I am getting compilation error when calling JaxWsDynamicClientFactory to
> generate a WS client in an osgi bundle deployed to SMX4.

This isn't completely unexpected.   The DynamicClient things call off to xjc 
to generate code, then they need to compile it.   On Java6, we can use the 
built in tools stuff to call the compiler which takes into account the 
classloader (I think).   On Java5, we have to call off to javac.  To do so, we 
need to build up a classpath.  With a normal app, we can traverse up the 
classloaders and find all the URLClassLoaders and grab the URL's for the Jars.   
For OSGi, we cannot do that.   Thus, it's not completely surprising that it's 
not working, but I also don't have a solution.

We could add a method to JaxWsDynamicClientFactory to allow you to set/force a 
classpath, but then you would need to discover and manage all that.   Beyond 
that, we would probably need a bundle listener or something that would record 
all the started bundles and create a classpath (if we can) and use that.   Not 
really sure.

Dan


> 
> Here is the error
> 
> 
> 
> /var/folders/-J/-J2E3X+EFWO9sX6IuLW2DE+++TI/-Tmp-/org.apache.cxf.jaxws.endp
> oint.dynamic.JaxWsDynamicClientFactory@81dd3c-1285253052600-src/com/melbour
> neit/provisionmanagement/client/ObjectFactory.java:216: cannot find symbol
>  symbol  : class JAXBElement
>  location: class com.melbourneit.provisionmanagement.client.ObjectFactory
>      public JAXBElement<String> createCustomerVOFirstName(String value) {
>             ^
> 
> /var/folders/-J/-J2E3X+EFWO9sX6IuLW2DE+++TI/-Tmp-/org.apache.cxf.jaxws.endp
> oint.dynamic.JaxWsDynamicClientFactory@81dd3c-1285253052600-src/com/melbour
> neit/provisionmanagement/client/ObjectFactory.java:225: cannot find symbol
>  symbol  : class JAXBElement
>  location: class com.melbourneit.provisionmanagement.client.ObjectFactory
>      public JAXBElement<String> createCustomerVOState(String value) {
> 
> Caused by: javax.xml.bind.JAXBException: Unable to create context
>  - with linked exception:
> [java.lang.NoSuchMethodException:
> com.sun.xml.bind.v2.ContextFactory.createContext(java.lang.String,
> java.lang.ClassLoader)]
> 	at javax.xml.bind.ContextFinder.find(ContextFinder.java:72)
> 	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:77)
> 	at
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicCl
> ientFactory.java:340) ... 37 more
> Caused by: java.lang.NoSuchMethodException:
> com.sun.xml.bind.v2.ContextFactory.createContext(java.lang.String,
> java.lang.ClassLoader)
> 	at java.lang.Class.getMethod(Class.java:1581)
> 	at javax.xml.bind.ContextFinder.find(ContextFinder.java:69)
> 	... 39 more
> 
> 
> Here is the code to invoke the factory
> 
> JaxWsDynamicClientFactory factory =
> JaxWsDynamicClientFactory.newInstance(); Client client =
> factory.createClient(getClass().getClassLoader().getResource("abc-wsdl.xml"
> ) .toExternalForm(), PROVISION_MANAGEMENT_WSDL_SERVICE_NAME);
> 
>         // client.
>         ClientImpl clientImpl = (ClientImpl) client;
> 
> 
> The code works perfectly when running as standalong app but fails in the
> osgi container.
> 
> 
> Thanks

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

Mime
View raw message