When I placed BshServlet in the same war file as my
application (so bsh-2.0b1.jar ended up in the same dir as
my other server side jars webapp/web-inf/lib). The
BshServlet was unable to 'see' any of the classes loaded
by the servlet's classloader.
When I dumped
bsh.servlet.BshServlet.class.getClassLoader() and did
the same with one of my other servlets I determined
that both servlets were being loaded by the same
classloader (which is good!) but when I placed some
debugging code in the BeanShell code I discovered
seemed to return the default java VM classloader not
Tomcat's adaptive classloader.
Not completely sure that I know what I was doing ;)
But the following fixed it for me..
public Class plainClassForName( String name )
// Requires JDK 1.2+
// GRF: When dealing with servlets this screws us up!
// GRF: ClassLoader contextClassLoader =
// GRF: Thread.currentThread().getContextClassLoader
// GRF: So replaced by
ClassLoader contextClassLoader = null;
if ( contextClassLoader != null )
return Class.forName( name, true,
return super.plainClassForName( name );
Anyway... this got me moving ahead... Whether this is a
bug may be up for debate. I just know that I had to do
this to get my classes visible.