Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 18565 invoked from network); 24 Jun 2002 18:34:48 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 24 Jun 2002 18:34:48 -0000 Received: (qmail 25828 invoked by uid 97); 24 Jun 2002 18:34:34 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 25781 invoked by uid 97); 24 Jun 2002 18:34:33 -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 25742 invoked by uid 98); 24 Jun 2002 18:34:31 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Message-ID: <00ac01c21bae$1984d3b0$0d01a8c0@PIFileServer> From: "Andreas Hirner" To: "Tomcat Users List" Cc: "Robert Priest" References: <93C0BE6A6D6AD211BC7400A0C9D8FE8705A366B8@exton1.bentley.com> Subject: Re: how do I load a native library? Date: Mon, 24 Jun 2002 20:36:42 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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:andreas@projektinter.net] > Sent: Monday, June 24, 2002 1:33 PM > To: Tomcat Users List > Cc: Robert.Priest@bentley.com > 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: > > > > For additional commands, e-mail: > > > > > > -- > > To unsubscribe, e-mail: > > > For additional commands, e-mail: > > > > > > > > > > -- To unsubscribe, e-mail: For additional commands, e-mail: