You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by xiaotao183 <xi...@gmail.com> on 2010/09/23 16:59:37 UTC

Not able to compile wsdl file using JaxWsDynamicClientFactory

Hi all,

I am getting compilation error when calling JaxWsDynamicClientFactory to
generate a WS client in an osgi bundle deployed to SMX4.

Here is the error



/var/folders/-J/-J2E3X+EFWO9sX6IuLW2DE+++TI/-Tmp-/org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory@81dd3c-1285253052600-src/com/melbourneit/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.endpoint.dynamic.JaxWsDynamicClientFactory@81dd3c-1285253052600-src/com/melbourneit/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(DynamicClientFactory.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
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Not-able-to-compile-wsdl-file-using-JaxWsDynamicClientFactory-tp2851331p2851331.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Not able to compile wsdl file using JaxWsDynamicClientFactory

Posted by xiaotao183 <xi...@gmail.com>.
Hi,

I use Mac jre 5.
I also deployed the same bundle to centOS which has jdk 5 installed but got
the same error.

I manually installed the jaxb-impl and jaxb-api 2.1 as osig bundle using bnd
to servicemix, no help either.
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Not-able-to-compile-wsdl-file-using-JaxWsDynamicClientFactory-tp2851331p2852113.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Not able to compile wsdl file using JaxWsDynamicClientFactory

Posted by Willem Jiang <wi...@gmail.com>.
Hi

What kind of JDK are you using?
It looks like a JAXB impl version issue.

On 9/23/10 10:59 PM, xiaotao183 wrote:
>
> Hi all,
>
> I am getting compilation error when calling JaxWsDynamicClientFactory to
> generate a WS client in an osgi bundle deployed to SMX4.
>
> Here is the error
>
>
>
> /var/folders/-J/-J2E3X+EFWO9sX6IuLW2DE+++TI/-Tmp-/org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory@81dd3c-1285253052600-src/com/melbourneit/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.endpoint.dynamic.JaxWsDynamicClientFactory@81dd3c-1285253052600-src/com/melbourneit/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(DynamicClientFactory.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


-- 
Willem
----------------------------------
Apache Camel, Apache CXF committer
Open Source Integration: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang

Re: Not able to compile wsdl file using JaxWsDynamicClientFactory

Posted by Daniel Kulp <dk...@apache.org>.
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