Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Ganesha Duggirala
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?

Ulf Dittmer
Posts: 42968
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic