portals-jetspeed-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jilles van Gurp <incom...@jillesvangurp.com>
Subject Re: J2 with JNI
Date Thu, 04 Aug 2005 13:29:24 GMT
I looked into the behaviour of static initializers and classloaders 
recently. Static initializers are called once upon loading the class. If 
subsequent classloaders load the same class, the static initializers are 
not executed. Only if the classloader that executed the initializer is 
destroyed and garbage collected are the static initializers executed 
again if you reload the class.

That might explain why it doesn't work for you. Some other classloader 
has loaded the class before tomcat loads the portlet webapp using a 
different classloader. Consequently, the static initializer has already 
executed.

To verify this theory you could perhaps log some details about the 
classloader in the static initializer and the init method.

Regards,

Jilles

Shah Amit wrote:
> Hi all,
>
> I have a J2 Portal application that uses JNI to make some native 
> calls. I do --
>
>
> static {
> logger.debug("About to load library");
> System.loadLibrary("myLibrary");
> logger.debug("Library Loaded");
> }
>
> in one of my classes (a spring bean), and I do see the "Library 
> Loaded" debug which means that my library IS getting loaded. However 
> when I try to call the native methods, I get "UnsatisfiedLink" 
> exception. I believe the problem is that Tomcat uses different class 
> loaders per web-application, and since the library is loaded in my web 
> application class loader and not in jetspeed's class loader, I am 
> getting that error. I am not 100% sure if I am correct over here 
> though. Any suggestions, ideas ?? ...
>
> Thanks,
> Amit
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Mime
View raw message