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() {