# 
# The following statement executes a Java class that uses XMLDecoder to instantiate 
# a class from an XMLEncoded xml file. I have required the jar that has the class being 
# instantiated. I can create an instance of the class directly however when I execute 
# this code I get a ClassNotFoundException.
# 
bundleManager.addBundles(configUrl.openStream)
java.lang.ClassNotFoundException: net.sf.sail.core.service.impl.CurnitUrlProviderImpl
#
# I think the reason is because XMLDecoder uses a thread context classloader
# and bypasses the JRuby class loader.
#
# Some forensics:
#
# make a new instance of a random class I loaded from a jar I required
#
b = SailCoreBundle::BundleManager.new
# => #
#
# get the JRuby classloader
#
jcl = b.getClass.getClassLoader
# => #
#
# get the current thread
#
t = java.lang.Thread.currentThread          
# => #
#
# get the thread context classloader
#
tcl = t.getContextClassLoader
# => #<#:0x9b3c58 @java_object=sun.misc.Launcher$AppClassLoader@a9c85c>
#
# the thread context classloader is the parent of the JRuby classloader
#
jcl.getParent == tcl
# => true