Hi,
The servlet is loading the library all right when it is placed on
the LD_LIBRARY_PATH but it is still giving
an error : "Unsatisfied Link Error" when the particular method is
called. I am using a support class to load the Native library and
calling the method using
new NativeLibLoader.NativeMethod();
Should this support class be placed in the server classpath as opposed
to the servlet directory ? The servlet does not seem to find the class
when it is put in the server's classpath(In Apache's servlet engine
we have done this using
wrapper.classpath = <dir>
in the jserv.properties file)
Both java.library.path and sun.boot.library.path are null.
Has anybody used JNI from Apache JServ ? Is it possible to load the
library directly from servlet?
I'd be very grateful for any help..
On Fri, 30 Jul 1999, Ted Neward wrote:
> Actually, that's not true, according to "Essential JNI", by Rob Gordon. Pp
> 16-17 read:
>
> "In order for System.loadLibrary to find your native library, the directory
> in which teh Shared Object Library file resides must appear in the
> LD_LIBRARY_PATH environment variable. On UNIX systems, the LD_LIBRARY_PATH
> environment variable is a colon-separated list of directory names. [....]
> "On Win32 systems the PATH environment variable is used to located dynamic
> link libraries. The PATH value is a list of directory names separated by
> semicolons. [...]
> "On both platforms, the list is searched in order for a file which matches
> the modified argument to System.loadLibrary."
>
> I can't find anything in the JNI Specification which describes precisely
> where it will look for native libs; both it and the
> System.loadLibrary/Runtime.loadLibrary method calls are very vague about the
> whole process, probably to avoid excluding any platform accidentally.
>
> If you look in the java.lang.ClassLoader source, at the end of the file
> you'll find an inner class, NativeLibrary, that provides most of the support
> for finding native libs. Inside of that code, after some digging around,
> you'll find that two system properties appear to be the core of what gets
> searched when a loadLibrary() call is executed:
>
> usr_paths = initializePath("java.library.path");
> sys_paths = initializePath("sun.boot.library.path");
>
> These two arrays of Strings, usr_paths and sys_paths, I believe correspond
> to the user-configurable and the JVM-reserved arrays of directories,
> respectively. Executing this code:
>
> public class NativeLib
> {
> public static void main(String[] args)
> {
> System.out.println("java.library.path=" +
> System.getProperty("java.library.path"));
> System.out.println("sun.boot.library.path=" +
> System.getProperty("sun.boot.library.path"));
> }
> }
>
> on a Win32 platform yields:
>
> E:\Test>java NativeLib
> java.library.path=C:\prg\java\jdk1.2.1\bin;.;C:\WINNT40\System32;C:\WINNT40;
> C:\p
> rg\java\jdk1.2.1\bin;C:\WINNT40\system32;C:\WINNT40;C:\Program
> Files\Mts;C:\prg\
> BC5\BIN;;C:\Prg\vslick\win;C:\Prg\bin;C:\Prg\WinCVS1.0.6
> sun.boot.library.path=C:\prg\java\jdk1.2.1\jre\bin
>
> E:\Test>
>
> where the first is my PATH environment variable, and the second is
> apparently coming from within the JVM itself (C:\prg\java\jdk1.2.1 is where
> my JDK is installed).
>
> Hopefully this yields some insight; comments/flames/questions welcome.
>
> Ted Neward
> Patterns/C++/Java/CORBA/EJB/COM-DCOM spoken here
> http://www.javageeks.com/~tneward
> "I don't even speak for myself; my wife won't let me." --Me
>
> -----Original Message-----
> From: Chris Pratt <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Tuesday, July 27, 1999 9:28 AM
> Subject: Re: related to jni
>
>
> >Because most servlet engines use custom classloaders, to implement the
> >automatic upgrading of servlets, you must ensure that your JNI classes are
> >found on the standard CLASSPATH, and NOT by the servlet engines custom
> >classloader (usually the servlets directory is out).
> > (*Chris*)
> >
> >----- Original Message -----
> >From: JESS ZACHARIAS <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Thursday, July 29, 1999 12:44 AM
> >Subject: related to jni
> >
> >
> >> hi!
> >>
> >> i'am encountering a problem while using native methods from my
> servlets.
> >> the servlet engine used is Apache_Jserv 1.0. the webserver is installed
> on
> >> linux.the shared library path is /usr/lib. when a request is made to the
> >> native method the error got is unsatisfied link error. the file exists
> and
> >> also the permissions are set right.
> >>
> >> can you suggest me, what could be possibly wrong?
> >>
> >> thank you.
> >>
> >>
> >___________________________________________________________________________
> >> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> >body
> >> of the message "signoff SERVLET-INTEREST".
> >>
> >> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >> Resources: http://java.sun.com/products/servlet/external-resources.html
> >> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >>
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html