I wish to create a naming Context from a beanshell script
that then calls, basically, an ejb in an appserver.
To do this one must know the host, jndi port,
the initial context factory class name and be able to
load the initial context factory class from within
Sun's naming classes (javax/naming/spi/NamingManager calls
com/sun/naming/internal/VersionHelper12 which uses
the current thread's ContextClassLoader).
Now I call this beanshell script from a bash shell script
which executes Ant and the script is simply a scripted
task within the Ant xml file.
I do not want to (really can't) load any of the application
classes into the classpath in the bash shell script; I use the
BshClassManager addClassPath method to load the application
jar as well as the appserver's client jar which contains the
jndi initial context factory class.
The beanshell script calls application objects which in turn
attempt to create an InitialContext object having set the
initial context factory property to be the name of the
appserver's initial context factory class.
Well, because the application and appserver classes are loaded into
the BshClassManager class loader, they are NOT in the
thread local ContextClassLoader which is what Sun's
naming classes use to create the initial context factory class!!!
If, for example, I explicitly set the thread local ContextClassLoader
to the BshClassManager, then I get a circularity error while loading
because it calls the thread ContextClassLoader to load classes
which where not explicity loaded into it.
So, how do I load classes into beanshell that can be visible
by the thread local ContextClassLoader???