Yeah, the classloader thing worked.
Thanks
/Tomas
On 3/25/11 8:31 PM, Daniel Kulp wrote:
On Friday 25 March 2011 1:09:24 PM Tomas Olsson wrote:
Hi again,
By furthur investigation I am quite sure that the reason that my setup
does not work is because of the namespace-package mapping. So, how do I
change the JAXB default package name for the JaxWsDynamicClientFactory?
I suspect it is in JAXB context properties but I do not know how to do
that.
The createClient call has an optional List<String> of binding files. Thus,
you can create a jaxb binding file to remap package names.
If you have the cxf-tools-common dependency, you can easily create one with:
File file = org.apache.cxf.tools.utilJAXBUtils
.getPackageMappingSchemaBindingFile(ns, pkg);
and pass the URL to that file in.
HOWEVER, this may be a classloader thing. Creating the client results in
the thread contextClassLoader being reset to the classloader that has all the
generated classes in it. Thus, you MAY be able to do:
ClassLoader loader = Thread.currentThread().getContextClassLoader();
deviceClient1 = dcf.createClient(wsdlURL1);
Thread.currentThread().setContextClassLoader(loader);
deviceClient2 = dcf.createClient(wsdlURL2);
Dan
/Tomas
On 3/25/11 2:09 PM, Tomas Olsson wrote:
Hi,
I have stumbled on this annoying problem (CXF 2.3.2), if I want to
create two dynamic clients like this:
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
deviceClient1 = dcf.createClient(wsdlURL1);
deviceClient2 = dcf.createClient(wsdlURL2);
But only the first one will work properly. When I call the second one
it does not find the generated classes (the same if I shift their
creation order, the last created will not work properly). I believe
the problem can be due to both having the same namespace. Part of the
exception below:
WARNING: Interceptor for
{http://tempuri.org/}BasicSwitchWS#{http://tempuri.org/}GetSwitchStatus
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error:
org.tempuri.GetSwitchStatus is not known to this context
at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:2
56)
at
org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(A
bstractOutDatabindingInterceptor.java:110)
at
org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterc
eptor.java:68)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorCh
ain.java:255)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
Is there any workaround? I cannot change their namespaces.
/Tomas