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:[EMAIL PROTECTED]] Gesendet: Montag, 24. Juni 2002 13:43 An: Tomcat Users List Cc: [EMAIL PROTECTED] 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:[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]>
