I need to provide a custom implementation of RMIClassLoaderSpi
for my application running in Tomcat. However, it seems that this class needs to be loaded using the System Classloader.
Does anyone know of a good way to provide a class to Tomcat such that it can be loaded using the System Classloader?
I'm aware that I can set the shared.loader and server.loader properties, but as far as I can see these wont' affect the System Classloader.
If anyone's interested, this is the code which is forcing the use of the System Classloader in RMIClassLoader:
Class providerClass =
Class.forName(providerClassName, false,
ClassLoader.getSystemClassLoader());
Where providerClass
is the name of my custom implementation of RMIClassLoaderSpi
.
Looking into this a bit more, it seems that I can modify setenv.sh to set the CLASSPATH variable, which is then propagated to the system classpath.
From catalina.sh:
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.
CLASSPATH=
if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
. "$CATALINA_BASE/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
. "$CATALINA_HOME/bin/setenv.sh"
fi
So it looks like this is the "intended" way to do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.