From 2a8e6546c28ff0f1603d16cf7c814090e9225bef Mon Sep 17 00:00:00 2001 From: edwardsmj Date: Tue, 4 Aug 2009 21:24:11 +0000 Subject: Fix classloading problem with Axis dependencies used by binding-ws-axis2 on references that use this binding: force TCCL for those dependencies to be the OSGi Bundle ClassLoader when running under OSGi git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@800984 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/ws/axis2/Axis2ServiceClient.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'java/sca/modules/binding-ws-axis2/src') diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java index d2ba46a7e2..09e64b836c 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java +++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java @@ -126,7 +126,12 @@ public class Axis2ServiceClient { * Create an Axis2 ServiceClient */ protected ServiceClient createServiceClient() { - try { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + ClassLoader axiscl = this.getClass().getClassLoader(); + + try { + if( axiscl != tccl ) Thread.currentThread().setContextClassLoader(axiscl); + final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding); ConfigurationContext configContext; @@ -145,7 +150,7 @@ public class Axis2ServiceClient { // configureSecurity(); } catch (PrivilegedActionException e) { throw new ServiceRuntimeException(e.getException()); - } + } // end try createPolicyHandlers(); @@ -171,7 +176,7 @@ public class Axis2ServiceClient { } } } - } + } // end if AxisService axisService = createClientSideAxisService(definition, serviceQName, port.getName(), new Options()); @@ -188,7 +193,7 @@ public class Axis2ServiceClient { configContext.setThreadPool(new ThreadPool(1, 5)); configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); - } + } // end if return new ServiceClient(configContext, axisService); @@ -200,8 +205,11 @@ public class Axis2ServiceClient { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); - } - } + } finally { + // Restore the Thread Context ClassLoader... + if( axiscl != tccl ) Thread.currentThread().setContextClassLoader(tccl); + } // end try + } // end method createServiceClient /** * URI resolver implementation for XML schema -- cgit v1.2.3