Return-Path: X-Original-To: apmail-axis-java-commits-archive@minotaur.apache.org Delivered-To: apmail-axis-java-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E30D310B6C for ; Thu, 13 Mar 2014 07:54:32 +0000 (UTC) Received: (qmail 63581 invoked by uid 500); 13 Mar 2014 07:54:32 -0000 Delivered-To: apmail-axis-java-commits-archive@axis.apache.org Received: (qmail 63540 invoked by uid 500); 13 Mar 2014 07:54:23 -0000 Mailing-List: contact java-commits-help@axis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@axis.apache.org Delivered-To: mailing list java-commits@axis.apache.org Received: (qmail 63524 invoked by uid 99); 13 Mar 2014 07:54:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Mar 2014 07:54:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Mar 2014 07:54:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1701F23888E4 for ; Thu, 13 Mar 2014 07:53:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1577055 - /axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java Date: Thu, 13 Mar 2014 07:53:58 -0000 To: java-commits@axis.apache.org From: veithen@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140313075358.1701F23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: veithen Date: Thu Mar 13 07:53:57 2014 New Revision: 1577055 URL: http://svn.apache.org/r1577055 Log: Fixed a class loading issue in the OSGi bundle. Modified: axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java Modified: axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java?rev=1577055&r1=1577054&r2=1577055&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java (original) +++ axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java Thu Mar 13 07:53:57 2014 @@ -73,20 +73,32 @@ public class OSGiServerConfigurator exte } public AxisConfiguration populateAxisConfiguration(InputStream in) throws DeploymentException { - axisConfig = new AxisConfiguration(); - AxisConfigBuilder builder = - new AxisConfigBuilder(in, axisConfig, this); - builder.populateConfig(); + // Dirty hack necessary because class loading in AxisConfigBuilder is completely broken: + // although it is possible to configure the class loaders explicitly in the AxisConfiguration, + // the AxisConfigBuilder will still use the thread context class loader in some places. + // On the other hand, in an OSGi environment, the TCCL is not well defined. To avoid problems, + // we set it to the class loader of the Axis2 OSGi bundle. + Thread currentThread = Thread.currentThread(); + ClassLoader savedTCCL = currentThread.getContextClassLoader(); + currentThread.setContextClassLoader(OSGiServerConfigurator.class.getClassLoader()); try { - if (in != null) { - in.close(); + axisConfig = new AxisConfiguration(); + AxisConfigBuilder builder = + new AxisConfigBuilder(in, axisConfig, this); + builder.populateConfig(); + try { + if (in != null) { + in.close(); + } + } catch (IOException e) { + String msg = "Error in closing input stream"; + throw new DeploymentException(msg, e); } - } catch (IOException e) { - String msg = "Error in closing input stream"; - throw new DeploymentException(msg, e); + //TODO: if module deployer neede to set it should be set here. + return axisConfig; + } finally { + currentThread.setContextClassLoader(savedTCCL); } - //TODO: if module deployer neede to set it should be set here. - return axisConfig; } public void loadServices() {