The problem is that the classloader that originally loaded the library has
been destroyed(by reload) and a new one is created. Since the classloader
has been destroyed, its classes are unavailable for access, therefore the
library that you loaded is unavailable. This is why you get 'unstaisfied
link' errors. 

The unfortunate downside is that the JVM remembers that your library was
loaded at some point and doesn't allow you to reload it.  

your code must be in \tomcat\common\classes(or lib) to *guarnatee* that it
will only be loaded once. Any servlet in \WEB-INF\classes will be reloaded
when the context is reloaded, or can be loaded multiple times depending on
your server.xml settings. It is best to move your loadlibrary() into a
simple singleton class that doesn't change often and can be put in the
common directory.

Charlie


> -----Original Message-----
> From: Collins, Jim [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 04, 2002 4:47 AM
> To: 'Tomcat Users List'
> Subject: RE: Ahh Native Library Hell
> 
> 
> Hi Charlie,
> 
> I did read the post and I fully understand why you cannot 
> load a native
> library twice. I am not sure however what the repercussions 
> are if I do try
> to load the same library again, I know that it will throw an 
> exception but
> can I not just catch this and then ignore it knowing that the 
> library must
> have been loaded.
> 
> Anyway to get around the problem of loading the library twice 
> I have moved
> the code that does this to another servlet that will only be 
> loaded once. I
> have explained this in my original post, do you have any idea 
> what I need to
> set so that I don't get the java.lang.UnsatisfiedLinkError in this new
> servlet.
> 
> Many thanks
> 
> Jim.
> 
> > -----Original Message-----
> > From: Cox, Charlie [mailto:[EMAIL PROTECTED]]
> > Sent: 03 July 2002 19:14
> > To: 'Tomcat Users List'
> > Subject: RE: Ahh Native Library Hell
> > 
> > 
> > I just answered this last week. see the thread "Native 
> > library cannot be
> > loaded twice" in the archives
> > 
> > Charlie
> > 
> > > -----Original Message-----
> > > From: Collins, Jim [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, July 02, 2002 1:30 PM
> > > To: 'Tomcat Users List'
> > > Subject: Ahh Native Library Hell
> > > 
> > > 
> > > Hi all,
> > > 
> > > I have been having a lot of trouble trying to get a servlet 
> > > to call some
> > > native methods. My first servlet I deployed via the manager 
> > > app, the first
> > > time everything went OK. When I removed the app and deployed 
> > > it again I got
> > > errors because the native library had already been loaded, I 
> > > know why this
> > > happens and thought I could just catch the exception and 
> > > ignore it and then
> > > call my native methods. This did not work however and the 
> > > code just hung in
> > > the native method call.
> > > 
> > > 
> > > What I have now tried to do is deploy a very simple servlet 
> > > as a war file
> > > and simply loads the native library and then calls a couple 
> > > of init methods.
> > > This servlet will not be redeployed so it is should be OK. 
> > > The servlet loads
> > > the native library with no problem but now when it calls a 
> > > native method I
> > > get:
> > > 
> > > java.lang.UnsatisfiedLinkError: dmSetConfigFile
> > > "snip"
> > > 
> > > The servlet that I loaded with the manager app could call 
> > > native methods
> > > without any problems but this servlet can't. Has anyone any 
> > > ideas at all
> > > what I can do? I have searched through the mail archives with 
> > > no luck. I am
> > > running Tomcat 4.1.3 on Solaris 8 using jdk 1.4. I have put 
> > > the library and
> > > jar file in <Jakarta_home>/common/lib. I have set the 
> > > LD_LIBRARY_PATH to
> > > point to where the library is, however I load the library with
> > > System.load("/home/me/jakarta-tomcat-4.1.3/common/lib/libDm3.1
> > > .6_NativeBridg
> > > e.so.1") not loadLibrary.
> > > 
> > > Thanks for your help.
> > > 
> > > Jim.
> > > 
> > > 
> > > PLEASE READ: The information contained in this email is 
> confidential
> > > and intended for the named recipient(s) only. If you are not 
> > > an intended
> > > recipient of this email you must not copy, distribute or take any 
> > > further action in reliance on it and you should delete it and 
> > > notify the
> > > sender immediately. Email is not a secure method of 
> > communication and 
> > > Nomura International plc cannot accept responsibility for 
> > the accuracy
> > > or completeness of this message or any attachment(s). Please 
> > > examine this
> > > email for virus infection, for which Nomura International 
> > plc accepts
> > > no responsibility. If verification of this email is sought 
> > then please
> > > request a hard copy. Unless otherwise stated any views or opinions
> > > presented are solely those of the author and do not 
> > represent those of
> > > Nomura International plc. This email is intended for informational
> > > purposes only and is not a solicitation or offer to buy or sell
> > > securities or related financial instruments. Nomura 
> > > International plc is
> > > regulated by the Financial Services Authority and is a 
> member of the
> > > London Stock Exchange.
> > > 
> > > 
> > > 
> > > --
> > > 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]>
> > 
> 
> 
> PLEASE READ: The information contained in this email is confidential
> and intended for the named recipient(s) only. If you are not 
> an intended
> recipient of this email you must not copy, distribute or take any 
> further action in reliance on it and you should delete it and 
> notify the
> sender immediately. Email is not a secure method of communication and 
> Nomura International plc cannot accept responsibility for the accuracy
> or completeness of this message or any attachment(s). Please 
> examine this
> email for virus infection, for which Nomura International plc accepts
> no responsibility. If verification of this email is sought then please
> request a hard copy. Unless otherwise stated any views or opinions
> presented are solely those of the author and do not represent those of
> Nomura International plc. This email is intended for informational
> purposes only and is not a solicitation or offer to buy or sell
> securities or related financial instruments. Nomura 
> International plc is
> regulated by the Financial Services Authority and is a member of the
> London Stock Exchange.
> 
> 
> 
> --
> 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]>

Reply via email to