Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 83587 invoked from network); 24 Jun 2002 13:02:14 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 24 Jun 2002 13:02:14 -0000 Received: (qmail 8995 invoked by uid 97); 24 Jun 2002 13:01:50 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 8885 invoked by uid 97); 24 Jun 2002 13:01:49 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 8639 invoked by uid 98); 24 Jun 2002 13:01:46 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Reply-To: From: "franzR" To: "Tomcat Users List" Subject: AW: Native library cannot be loaded twice Date: Mon, 24 Jun 2002 15:02:38 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Importance: Normal In-Reply-To: <009201c21b74$49afa7c0$0d01a8c0@PIFileServer> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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: For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: