• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Load native library in application context and unload/load with application

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm currently using System.loadLibrary in a static block to load a native c++ library. However, if i redeploy my web app that loads this library, i get unsatisfiedlink error since the redeployed app tries to load the native library again during the JNI call and fails since the library is already loaded in memory.

Is there any way to load the library specific only to the web application in the application context and not the system context? I basically want the library to be unloaded when i undeploy or redeploy the web application. I do not want the library to be available to any other application other than mine (I know some of you will say that this defeats the purpose of having a library and load it only in a particular application context but that's what I need to do) and hence i want it to be available as part of my web application.

Also where can i place the native library under my application path so that it can be accessed by my application and not particularly via one of the directories in LD_LIBRARY_PATH? In WEB-INF folder or some other folder?

Thanks,
Ganesh
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was discussed recently: https://coderanch.com/t/474442/Web-Services/java/include-native-library-with-webservice
 
reply
    Bookmark Topic Watch Topic
  • New Topic