Hi Robert,
> Well, I am running on W2k box.
> We also call System.loadLibrary in our code, and we don't have any
problem.
> Our classes are in common\lib also:
>
> static
> {
> System.loadLibrary(STR_LIBRARY);
> isLoaded = true;
> }
>
> Also, I believe that even if you do call System.loadLibrary in
multiple
> places, the subsequent calls will be ignored.
That''s the problem. If I include the static block in a servlet and
exute it, everything works fine. But if I make changes to the servlet
and reload it using the manager/reload function and call the servlet
again it crashes. Thats why I am trying to put the the loadLibrary
call further up in the hierarchy.
> Could be that weird Tomcat Classloader/Library issue.
>
> You could try sticking you InitMapServer.class (or jar) in the
common/lib
> AND any class that needs to call it, also stick that in common/lib
(or
> class, whatever the case may be). The point being that any class
that uses
> it (InitMapServer) is being loaded by the same classloader.
This is the piece of code I used in the servlet instead of the static
block to load InitMapscript
################
public void init(ServletConfig config) throws ServletException
{
try
{
Class.forName("InitMapserver");
} catch (ClassNotFoundException ex) {
throw new ServletException(ex.getMessage() + "Class InitMapserver
not found");
file://System.err.println(ex.getMessage() + "Class InitMapserver
not found");
}
}
################
and I think this call does not load the native library correctly
because I get a UnsatisfiedLinkError exception after calling the first
native method.
Cheers Andy
> -----Original Message-----
> From: Andreas Hirner [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 24, 2002 1:33 PM
> To: Tomcat Users List
> Cc: [EMAIL PROTECTED]
> Subject: Re: how do I load a native library?
>
>
> Hi
>
> > Unless I am missing something, it looks like it should work.
> > is "mapscript" the name of your dll?
> I am working on Linux, so the shared library is called
libmapscript.so
>
> > Is "mapscript.dll" in your PATH?
> as far as I am concerned the path to shared libraries is set in the
> LD_LIBRARY_PATH variable and this is what I did. If I inculde the
> static block listed in script below in a servlet and call the native
> methods it works. That's why I think that the mistake has something
to
> do with way I call library in the InetMapserver class.
>
> Thanks Andreas
>
>
> > Hi,
> >
> > I would like to load a native library for all applications in the
> > common/lib directory.
> > So I wrote the following code:
> >
> > public class InitMapserver
> > {
> > static
> > {
> > try {
> > System.loadLibrary("mapscript");
> > System.err.println("libmapscript.so loaded");
> > } catch (UnsatisfiedLinkError e) {
> > System.err.println("libmapscript.so not loaded: " + e);
> > }
> > }
> > }
> >
> > then I created a jar file and copied it into the common/lib
> directory.
> > After restarting tomcat, I called the class in a servlet using the
> > Class.forName method. Unfortunately this does not work.
> >
> > What did I wrong?
> >
> > Thanks Andreas
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> >
>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>