Sorted out a classloading issue that was introduced when we switched to Commons VFS 2.0 - basically it makes correct use of the context classloader, so we need to make sure we have the context loader set properly when we go to setup the liaison objects for the hosted service.
So, we're back to the state we were at with RiverSurrogate in the skunk branch, except that the container is now built with Maven and source-controlled with Git. Container successfully starts Reggie. Project: http://git-wip-us.apache.org/repos/asf/river-container/repo Commit: http://git-wip-us.apache.org/repos/asf/river-container/commit/dc58e6ea Tree: http://git-wip-us.apache.org/repos/asf/river-container/tree/dc58e6ea Diff: http://git-wip-us.apache.org/repos/asf/river-container/diff/dc58e6ea Branch: refs/heads/master Commit: dc58e6ea2a2d38e86e248af2172797a67bd0ef09 Parents: 92921c3 Author: Greg Trasuk <gtra...@apache.org> Authored: Wed Aug 7 12:00:25 2013 -0400 Committer: Greg Trasuk <gtra...@apache.org> Committed: Wed Aug 7 12:00:25 2013 -0400 ---------------------------------------------------------------------- .../deployer/StarterServiceDeployer.java | 16 ++++++++++------ .../liaison/VirtualFileSystemConfiguration.java | 19 ++++++++++++++++--- .../services/net.jini.config.Configuration | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/river-container/blob/dc58e6ea/river-container-core/src/main/java/org/apache/river/container/deployer/StarterServiceDeployer.java ---------------------------------------------------------------------- diff --git a/river-container-core/src/main/java/org/apache/river/container/deployer/StarterServiceDeployer.java b/river-container-core/src/main/java/org/apache/river/container/deployer/StarterServiceDeployer.java index 9d5ad17..036441f 100644 --- a/river-container-core/src/main/java/org/apache/river/container/deployer/StarterServiceDeployer.java +++ b/river-container-core/src/main/java/org/apache/river/container/deployer/StarterServiceDeployer.java @@ -245,7 +245,9 @@ public class StarterServiceDeployer implements StarterServiceDeployerMXBean { /* Setup the liaison configuration. */ + ClassLoader originalContextCl=Thread.currentThread().getContextClassLoader(); try { + Thread.currentThread().setContextClassLoader(cl); File workingDir = null; if (serviceArchive != null) { workingDir = new File(serviceArchive.getURL().toURI()); @@ -270,19 +272,21 @@ public class StarterServiceDeployer implements StarterServiceDeployerMXBean { String contextVarName = cfgEntryNode.jjtGetChild(1).toString(); Object contextValue = context.get(contextVarName); if (contextValue != null) { - invokeStatic(cl, configName, - Strings.PUT_SPECIAL_ENTRY, - new Class[] {String.class, Object.class}, + invokeStatic(cl, configName, + Strings.PUT_SPECIAL_ENTRY, + new Class[]{String.class, Object.class}, Strings.DOLLAR + varName, contextValue); } else { - log.log(Level.WARNING, MessageNames.MISSING_SPECIAL_VALUE, - new Object[] {getConfig(), varName, contextVarName}); - } + log.log(Level.WARNING, MessageNames.MISSING_SPECIAL_VALUE, + new Object[]{getConfig(), varName, contextVarName}); + } } } catch (Exception ex) { log.log(Level.WARNING, MessageNames.EXCEPTION_THROWN, Utils.stackTrace(ex)); throw new ConfigurationException(ex, MessageNames.STARTER_SERVICE_DEPLOYER_FAILED_INIT); + } finally { + Thread.currentThread().setContextClassLoader(originalContextCl); } } http://git-wip-us.apache.org/repos/asf/river-container/blob/dc58e6ea/river-container-core/src/main/java/org/apache/river/container/liaison/VirtualFileSystemConfiguration.java ---------------------------------------------------------------------- diff --git a/river-container-core/src/main/java/org/apache/river/container/liaison/VirtualFileSystemConfiguration.java b/river-container-core/src/main/java/org/apache/river/container/liaison/VirtualFileSystemConfiguration.java index 1e5c51a..c84f8dd 100644 --- a/river-container-core/src/main/java/org/apache/river/container/liaison/VirtualFileSystemConfiguration.java +++ b/river-container-core/src/main/java/org/apache/river/container/liaison/VirtualFileSystemConfiguration.java @@ -18,11 +18,10 @@ package org.apache.river.container.liaison; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -33,7 +32,6 @@ import net.jini.config.ConfigurationFile; import net.jini.config.ConfigurationNotFoundException; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemException; -import org.apache.commons.vfs2.FileSystemManager; import org.apache.commons.vfs2.VFS; /** @@ -58,6 +56,10 @@ public class VirtualFileSystemConfiguration @param workingDirectory */ public static void setWorkingDirectory(File workingDirectory) { + /* Before we do anything, setup the class loader for the vfs manager. + */ + + setManagerClassLoader(); try { if (workingDirectory.isDirectory()) { FileObject root = VFS.getManager().toFileObject(workingDirectory); @@ -81,6 +83,17 @@ public class VirtualFileSystemConfiguration } + private static void setManagerClassLoader() { + try { + Object mgr=VFS.getManager(); + Method setter=mgr.getClass().getMethod("setClassLoader", new Class[] {ClassLoader.class}); + setter.invoke(mgr, new Object[] {mgr.getClass().getClassLoader()}); + } catch (Throwable t) { + t.printStackTrace(); + } + + } + public static FileObject getRootDirectory() { return rootDirectory; } http://git-wip-us.apache.org/repos/asf/river-container/blob/dc58e6ea/river-container-core/src/main/resources/META-INF/services/net.jini.config.Configuration ---------------------------------------------------------------------- diff --git a/river-container-core/src/main/resources/META-INF/services/net.jini.config.Configuration b/river-container-core/src/main/resources/META-INF/services/net.jini.config.Configuration new file mode 100644 index 0000000..04defc2 --- /dev/null +++ b/river-container-core/src/main/resources/META-INF/services/net.jini.config.Configuration @@ -0,0 +1 @@ +org.apache.river.container.liaison.VirtualFileSystemConfiguration \ No newline at end of file