Forum Stats

  • 3,837,134 Users
  • 2,262,229 Discussions
  • 7,900,211 Comments

Discussions

dll on Tomcat 6 got UnsatisfiedLinkError ... Can't find dependent libraries

843829
843829 Member Posts: 49,201
edited Apr 13, 2011 9:49AM in Java Native Interface (JNI)
I created a dll file and it ran with no errors on the command line. But when i deployed it together with the java class file over to Tomcat 6.0\lib and ran it with a web application, Tomcat's log file reported:

Exception in thread "Thread-12" java.lang.UnsatisfiedLinkError: C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\Binless.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at jni.server.Binless.<clinit>(Unknown Source)
at org.brainml.analysisserver.queue.ProcessItemThread.run(ProcessItemThread.java:57)


Here is what I did:

Step 1: Compile and manifest

"%MSVCDir%\bin\cl.exe" /I"%JAVA_HOME%\include" /I"%JAVA_HOME%\include\win32" /MD /LD /FeBinless.dll ../info/binless/jni_binless.c ../jni_shared/jni_gen_c.c ../jni_entropy/jni_entropy_c.c ../../entropy/entropy_nsb_c.cpp /link libxml2.lib libgsl.a libgslcblas.a >> binless-out.txt

mt.exe -manifest Binless.dll.manifest -outputresource:Binless.dll;2

The operating system is Windows XP and has the following environment variables:

PATH=%JAVA_HOME%\bin;%LIBXMLDir%\bin;%ICONVDir%\bin;%GNUWINDir%\bin;%WINSDKDir%\bin;%MSVCDir%\bin;%MSVCDir%\..\Common7\IDE;%ZLIBDir%\bin;%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem

INCLUDE=%WINSDKDir%\include;%GNUWINDir%\include;%MSVCDir%\include;%MSVCDir%\PlatformSDK\include;%JAVA_HOME%\include;%JAVA_HOME%\include\win32;%LIBXMLDir%\include;%ICONVDir%\include;%ZLIBDir%\include

LIB=%WINSDKDir%\lib;%GNUWINDir%\lib;%MSVCDir%\lib;%MSVCDir%\PlatformSDK\lib;%LIBXMLDir%\lib;%ICONVDir%\lib;%ZLIBDir%\lib

where:

GNUWINDir=c:\project\lib\GnuWin32
ZLIBDir=c:\project\lib\zlib
ICONVDir=c:\project\lib\iconv
LIBXMLDir=c:\project\lib\libxml2
WINSDKDir=C:\Program Files\Microsoft SDKs\Windows\v6.0A
MSVCDir=C:\Program Files\Microsoft Visual Studio 9.0\VC

Step 2: Compile the Java jni code

javac -d ..\classes ..\server\Binless.java

Step 3: Ran the code

java -classpath ..\classes jni.test.test_binless

Successful with no errors.

Step 4: Copied Binless.dll and Binless.class in a jar file (Binless.dll NOT in the jar file) to Tomcat 6.0\lib, and then ran a web application that called the Binless class.

Got UnsatisfiedLinkError (see above) in Tomcat's log file.

Am I missing something? Any help is greatly appreciated. Thank you.

Comments

  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    snygg1 wrote:
    Exception in thread "Thread-12" java.lang.UnsatisfiedLinkError: C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\Binless.dll: Can't find dependent libraries
    ...
    Am I missing something?
    What part of the above error message did you not understand?
  • 843829
    843829 Member Posts: 49,201
    I don't understand why Binless.dll works from command line but not within Tomcat. I thought using mt.exe would embed the dependent libraries into the dll file but it doesn't seem to be the case here. Otherwise, Binless.dll would have worked regardless of where it's being located. The mt.exe doesn't seem to embed all the dependent libraries. In particular, MSVCR90.dll and DWMAPI.dll, which i found out using Dependency Walker. Why's that the case?

    Thanks.
  • EJP
    EJP Member Posts: 32,920 Gold Crown
    I thought using mt.exe would embed the dependent libraries into the dll file
    I don't know why. That's not what it is described as being for in the MS documentation.

    In any case this is clearly an MSVC question not a Java question.
  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    snygg1 wrote:
    I don't understand why Binless.dll works from command line but not within Tomcat. I thought using mt.exe would embed the dependent libraries into the dll file but it doesn't seem to be the case here. Otherwise, Binless.dll would have worked regardless of where it's being located. The mt.exe doesn't seem to embed all the dependent libraries. In particular, MSVCR90.dll and DWMAPI.dll, which i found out using Dependency Walker.
    None of that has anything to do with it.
    Why's that the case?
    In one case it finds the dependencies. In another it doesn't. For the second that means the PATH is wrong or the resources are not on the system.
  • 855044
    855044 Member Posts: 1
    Problem:- Hi i was trying to gererate a dll through make file using CL command using visual studio 2005 on windows 2008 (64 bit) machine. Although i was able to generate DLL file but while using this DLL file by JNI it was throwing can't find dependent libraries.

    1. I used Dependency walker to check for dependent dll's(error on msvcr80.dll and etc).
    2. On visual studio 2005 there are certain things: Visit link http://msdn.microsoft.com/en-us/library/ms235342(v=vs.80).aspx

    Solution:- I have added mt.exe -manifest ../../generated/MyLibrary.dll.manifest - outputresource:"../../generated/MyLibrary.dll;2" just after CL command ends. it runs successfully....

    cheers
    Abi...
This discussion has been closed.