You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christian Becker <ch...@dabecka.de> on 2007/05/02 15:25:47 UTC

JNI in Tomcat6

Hello Everybody,

i am currently developing a Servlet for Controlling my Winamp with my
Mobile.
The Library i want to use is jdic.
jdic uses JNI with a DLL

As Java Application, it is perfectly working.
But on my Tomcat6 i always get a Exception while Servlet Initialization:

java.lang.UnsatisfiedLinkError

This is caused while calling a Native Method.
I just tried several Places for the DLL but i always get the Exception.

Where do i have to place the DLL File, that the Classloader will find it?

The PATH Variable and a Subfolder \WEB-INF\libs seems to have no effects.

Thankyou,
Regards,
Christian Becker



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JNI in Tomcat6

Posted by Pid <p...@pidster.com>.
Caldarale, Charles R wrote:
>> From: Martin Gainty [mailto:mgainty@hotmail.com] 
>> Subject: Re: JNI in Tomcat6
>>
>> usually the binaries are located in %JAVA_HOME%/jre/bin
> 
> Only DLLs that are part of the JVM should be placed in
> %JAVA_HOME%/jre/bin; this is not an appropriate location for
> application-specific native code.
> 
>> change LD_LIBRARY_PATH in jvm.cfg to point to the folder 
>> containing your DLL
> 
> You can't set LD_LIBRARY_PATH in jvm.cfg (at least not in the one in
> %JAVA_HOME%/jre/lib/[arch] for a Sun-based JVM; I know of no other
> locations for jvm.cfg).  The jvm.cfg file is only for configuring which
> JVMs are available (just client and server, these days).  The jvm.cfg
> mechanism is expected to disappear when the client and server JVMs are
> finally integrated into a single JVM.  (If you want to see how jvm.cfg
> is processed, set the env var _JAVA_LAUNCHER_DEBUG to any value when you
> start the JVM from a command prompt.)

I'm feeling a bit of deja vu here.



> Now back to Christian's original question:
> 
>> Where do i have to place the DLL File, that the 
>> Classloader will find it?
> 
> The JVM finds native libraries by looking at the system property
> java.library.path.  On Windows, the default value of this property is
> taken from the PATH environment variable, prefixed with a few
> directories the JVM launcher knows about (e.g., C:\WINDOWS\system32).
> The LD_LIBRARY_PATH environment variable is not used at all on Windows.
> 
> On Linux/UNIX systems, the default java.library.path includes various
> directories from the JVM installation plus a few standard locations.
> For example, on one of our SUSE boxes, it's:
> 
> /common/jdk6/jre/lib/amd64/server:/common/jdk6/jre/lib/amd64:/common/jdk
> 6/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
> 
> On Linux/UNIX, the LD_LIBRARY_PATH environment variable can be used to
> modify the above list; whatever is specfied with that variable is
> inserted in the list just prior to the first /usr entry.
> 
> The default value can be overridden by specifying
> -Djava.library.path=<whatever> on the command line for any platform.  If
> Tomcat is running as a Windows service, you can use the tomcat?w.exe
> utility to set whatever value you want for the java.library.path
> property.  On a running Tomcat, use the System Information -> System
> Properties screen of Lambda Probe (www.lambdaprobe.org) to display all
> of the property names and values.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


RE: JNI in Tomcat6

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin Gainty [mailto:mgainty@hotmail.com] 
> Subject: Re: JNI in Tomcat6
> 
> usually the binaries are located in %JAVA_HOME%/jre/bin

Only DLLs that are part of the JVM should be placed in
%JAVA_HOME%/jre/bin; this is not an appropriate location for
application-specific native code.

> change LD_LIBRARY_PATH in jvm.cfg to point to the folder 
> containing your DLL

You can't set LD_LIBRARY_PATH in jvm.cfg (at least not in the one in
%JAVA_HOME%/jre/lib/[arch] for a Sun-based JVM; I know of no other
locations for jvm.cfg).  The jvm.cfg file is only for configuring which
JVMs are available (just client and server, these days).  The jvm.cfg
mechanism is expected to disappear when the client and server JVMs are
finally integrated into a single JVM.  (If you want to see how jvm.cfg
is processed, set the env var _JAVA_LAUNCHER_DEBUG to any value when you
start the JVM from a command prompt.)

Now back to Christian's original question:

> Where do i have to place the DLL File, that the 
> Classloader will find it?

The JVM finds native libraries by looking at the system property
java.library.path.  On Windows, the default value of this property is
taken from the PATH environment variable, prefixed with a few
directories the JVM launcher knows about (e.g., C:\WINDOWS\system32).
The LD_LIBRARY_PATH environment variable is not used at all on Windows.

On Linux/UNIX systems, the default java.library.path includes various
directories from the JVM installation plus a few standard locations.
For example, on one of our SUSE boxes, it's:

/common/jdk6/jre/lib/amd64/server:/common/jdk6/jre/lib/amd64:/common/jdk
6/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib

On Linux/UNIX, the LD_LIBRARY_PATH environment variable can be used to
modify the above list; whatever is specfied with that variable is
inserted in the list just prior to the first /usr entry.

The default value can be overridden by specifying
-Djava.library.path=<whatever> on the command line for any platform.  If
Tomcat is running as a Windows service, you can use the tomcat?w.exe
utility to set whatever value you want for the java.library.path
property.  On a running Tomcat, use the System Information -> System
Properties screen of Lambda Probe (www.lambdaprobe.org) to display all
of the property names and values.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JNI in Tomcat6

Posted by Martin Gainty <mg...@hotmail.com>.
Good Morning Dave

usually the binaries are located in %JAVA_HOME%/jre/bin
backup everything (jvm.cfg especially) you have beforehand
change LD_LIBRARY_PATH in jvm.cfg to point to the folder containing your DLL

(please verify this works as the signatures for JNI dll's need to conform to 
spec)
Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "David Kerber" <dc...@verizon.net>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Wednesday, May 02, 2007 9:34 AM
Subject: Re: JNI in Tomcat6


> Christian Becker wrote:
>
>>Hello Everybody,
>>
>>i am currently developing a Servlet for Controlling my Winamp with my
>>Mobile.
>>The Library i want to use is jdic.
>>jdic uses JNI with a DLL
>>
>>As Java Application, it is perfectly working.
>>But on my Tomcat6 i always get a Exception while Servlet Initialization:
>>
>>java.lang.UnsatisfiedLinkError
>>
>>This is caused while calling a Native Method.
>>I just tried several Places for the DLL but i always get the Exception.
>>
>>Where do i have to place the DLL File, that the Classloader will find it?
>>
>>The PATH Variable and a Subfolder \WEB-INF\libs seems to have no effects.
>>
> I'm not certain of this, but you could try putting it in your 
> <jre_home>/lib/ext/x86 folder.  That's where a 3rd party jni app that I 
> use wants its .dll's.
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JNI in Tomcat6

Posted by David Kerber <dc...@verizon.net>.
Christian Becker wrote:

>Hello Everybody,
>
>i am currently developing a Servlet for Controlling my Winamp with my
>Mobile.
>The Library i want to use is jdic.
>jdic uses JNI with a DLL
>
>As Java Application, it is perfectly working.
>But on my Tomcat6 i always get a Exception while Servlet Initialization:
>
>java.lang.UnsatisfiedLinkError
>
>This is caused while calling a Native Method.
>I just tried several Places for the DLL but i always get the Exception.
>
>Where do i have to place the DLL File, that the Classloader will find it?
>
>The PATH Variable and a Subfolder \WEB-INF\libs seems to have no effects.
>  
>
I'm not certain of this, but you could try putting it in your 
<jre_home>/lib/ext/x86 folder.  That's where a 3rd party jni app that I 
use wants its .dll's.

Dave



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org