tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: Sharing Native Library from parent classloader?
Date Mon, 09 Aug 2010 10:15:01 GMT
2010/8/7 Brock Noland <>:
> Hello,
> I have a legacy application written in C.  The library is wrapped in JAVA as
> the supporting applications are all JAVA based. The problem we are running
> into is that although the library is thread safe the java wrapper is not.
>  Changing the wrapper would be a major change. As such, we have to run many
> JVMs on a single host which is eating memory like crazy.  We have tens of
> thousands of these JVMs. My goal is to wrap around the non-thread safe
> wrapper and reduce JVM overhead.
> I remembered that Tomcat had different class loaders for each web
> application and have successfully been able to load two different wrappers
> from two "applications."  However, I cannot load the native library in the
> two classloaders. I understand this is JVM limitation. I do wonder, however,
> if I can load the library in a parent class loader?  I have tried this but I
> am getting UnsatisfiedLinkError when the native methods are called.
> Is there any workaround for this?  I see tomcat uses some native APR library
> and I was wondering if you have found a workaround? I see towards the bottom
> of this bug report, someone seems to have a hack regarding System.out.
> That probably would not fly for me.
> Thanks for your time,
> Brock Noland

1. This is a question for the users@ list, not dev@, because it is not
about improving Tomcat, but about running your webapp.

2. Tomcat Native library is loaded by
class, if it is present in server.xml. You can look at the sources,
but there is nothing special.

3. You must read this doc:

In essence, you have to put your jar in ${catalina.base}\lib  and at
the same time _remove_ it from your webapp. The result will be that it
will be loaded by the Common classloader.

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message