I developed and application which uses a dll to get data from windows registry, there is a dll located at a directory included in PATH environment variable. Ir works fine If I invoke it from and standalone application, but When I tested it from a Web App hosted in Tomcat, It throws a javalinkunsatisfiedException. It seems like TomCat gets a different value for PATH Variable.
- Where does TomCat get java.library.path value?
- How Can I include a new directory there, if I want to place the dll at C:\Program Files\Tomcat 5.0\comon\shared?
You must place the jar file that has the JNI Java classes in the {CATALINA_HOME}\shared\lib folder.
If the folder doesn't exist then create it.
The JNI DLL must be located somewhere visible from either the java.library.path java system property or the Path windows system (or user) property.
To set the java.library.path java system property with Tomcat simply set the JAVA_OPTS environment variable before executing {CATALINA_HOME}\bin\startup.bat:
set CATALINA_HOME=someTomcatRootFolder
set JAVA_HOME=someJavaRootFolder
set JAVA_OPTS=-Djava.library.path=someJniDllPath
cd "%CATALINA_HOME%\bin"
call startup.bat
I mean your custom made Java class(es) that use JNI calls (System.loadLibrary() and native methods).
You cannot place it(them) under your web application WEB-INF/lib or WEB-INF/classes folder because of multiple class loading problem with JNI in the same JVM.
You have to place it(them) under a common Tomcat folder.
It could be either under {CATALINA_HOME}\shared\lib as a custom made jar file or under {CATALINA_HOME}\shared\classes as your compiled .class files.
This ocurrs because There are 2 applications hosted at my Tomcat
This means that one (or both) your web application(s) is (are) using Java JNI classes that load the same native library and that those Java classes are NOT located under the Tomcat shared folder.
There must be NO Java JNI classes under any WEB-INF/classes or WEB-INF/lib folder.
Since I faced same problem (unsatisfiedLinkError), I followed the suggestions in this thread.
I created a lib containing a call to C dll. Works fine in stand alone app. Idropped this to [CATALINA_HOME]\shared\lib.
Netbeans recognised this lib and I'm able to build my web app.
Deploying my web app I'll get a class not found error, caused by the line caling my lib.:(
Any idea?
Deploying my web app I'll get a class not found error, caused by the line caling my lib.:(
Only way that would happen is if you are using a static initializer and not catching the exception when the library load fails.
As noted the system properties will tell you exactly what paths are available in the application by looking at the java.library.path in there when an app is running.
u want to place the dll in ur bin. else
say for an eg., u have x.dll
and you have your class in the project called y
y-> u have ur bin, src u have to place ur dll into the bin.
if u r using any web application, u have to place the dll into server bin
praveekan wrote:
u want to place the dll in ur bin. else
say for an eg., u have x.dll
and you have your class in the project called y
y-> u have ur bin, src u have to place ur dll into the bin.
if u r using any web application, u have to place the dll into server bin
I encountered the same problem while developing a Web App which calls a dll.
It throws ClassNotFound exception.
I have ensured that the dll is at a location which is listed under java.library.path.
Also, the classes which load the library are placed in Tomcat 5.0\shared\classes folder.
Thanks