tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "franzR" <reitinger.fr...@utanet.at>
Subject AW: Native library cannot be loaded twice
Date Mon, 24 Jun 2002 13:02:38 GMT
Concerning the JDK documentation a native lib should be loaded in a static
scope. Static resources are processed differently, because the runtime
systems has to initialize all static resources at the beginning. After that
the runtime system tries to initialize objects and these objects can - of
course - use all static resources.

A look into your code (InitMapserver) shows, that the runtime system cannot
initialize the static resource in the common way, because it first must
generate an object and this object contains code for doing some static
stuff. Maybe this is the reason for the strange behavior.

franzR

-----Urspr√ľngliche Nachricht-----
Von: Andreas Hirner [mailto:andreas@projektinter.net]
Gesendet: Montag, 24. Juni 2002 13:43
An: Tomcat Users List
Cc: hermod.opstvedt@dnb.no
Betreff: Re: Native library cannot be loaded twice




Hi

> Yes. But have you ensured that your native library and its
dependends
> are in the java.library.path ?
>
> Hermod

Tomcat runs on linux and the path of the native library is set via the
LD_LIBRARY_PATH variable. If I load the native library in the servlet,
the library is accessed correctly and does what it is supposed to do.
However, when I initialise the library in the InitMapserver class and
call it in the servlet via the class.forName method (see below) the
servlet does not work properly.

Andreas

############################################

> ok, I realised that I cannot load a native library twice. So I wrote
> and compiled a class called InitMapserver, which looks like that:
>
>
>  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);
>    }
>   }
>
>  }
>
> and put it into the common/classes directory. Then I try to load
this
> class in a servlet
> doing:
>
>  public void init(ServletConfig config) throws ServletException
>  {
>
>   try
>   {
>      Class.forName("InitMapserver");
>   } catch (ClassNotFoundException ex) {
>      file://throw new ServletException(ex.getMessage() + "Class
> InitMapserver not     found");
>      System.err.println(ex.getMessage() + "Class InitMapserver not
> found");
>   }
>  }




--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message