tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Sharing Native Library from parent classloader?
Date Mon, 09 Aug 2010 10:15:01 GMT
2010/8/7 Brock Noland <brockn@gmail.com>:
> 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.
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4225434
>
> 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
org.apache.catalina.core.AprLifecycleListener
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:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message