Results 1 to 9 of 9
  1. #1
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default UnsatisfiedLinkError on dll load

    Hi Friends,

    I have a sample piece of code in my application that loads a dll and use its methods...

    My code runs fine for the very first time and native methods get invoked properly...

    But when i try for the second time, loading dll fails with unsatisfiedlink error...if i quit and start my application, the dll load works for first time again and fails in future attempts...

    I am aware that my dll is still loaded by classloader...but someone please help me to get rid of this by unloading dll each time my task is done...

    Regards,
    Bharath M

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Bharath_M View Post
    Hi Friends,

    I have a sample piece of code in my application that loads a dll and use its methods...

    My code runs fine for the very first time and native methods get invoked properly...

    But when i try for the second time, loading dll fails with unsatisfiedlink error...if i quit and start my application, the dll load works for first time again and fails in future attempts...

    I am aware that my dll is still loaded by classloader...but someone please help me to get rid of this by unloading dll each time my task is done...

    Regards,
    Bharath M
    Do you quit your Java program before you attempt to load your .dll again, or do you simply try to load it again in the same 'incarnation' of your Java program. Loading a .dll for a second (or third etc.) time shouldn't harm you because the documentation explicitly states: "If this method is called more than once with the same library name, the second and subsequent calls are ignored.".

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default

    I quit my java program before i attempt to load my dll again...

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Bharath_M View Post
    I quit my java program before i attempt to load my dll again...
    So you run your program for the first time and everything runs ok; you try to run it again and the loading fails; you try to run it for a third time and everything is fine again, etc. etc. Is this assumption correct?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default

    Not really...It works for only the first time and fails on all of the future runs...

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Bharath_M View Post
    Not really...It works for only the first time and fails on all of the future runs...
    Ah, ok, my guess is that the OS is playing tricks on you: it doesn't unload the .dll when your application quits and no more references to the .dll exist. I don't know how to force MS Windows to immediately unload a .dll when it isn't needed anymore, sorry.

    What happens if you wait a bit before you restart your application again?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default

    Yes... i observed occasionally today that if i wait for some time, i get rid of this error...but dont know wat exactly needs to be done to fix this...

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Bharath_M View Post
    Yes... i observed occasionally today that if i wait for some time, i get rid of this error...but dont know wat exactly needs to be done to fix this...
    Does your .dll use sockets or other resources that linger after you've closed your application?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default

    No, i dont use any such sockets with my dll....so there might not be any lingering sockets as you suspect...there is something else happening which am not aware...

Similar Threads

  1. Java3D UnsatisfiedLinkError
    By Cemi in forum New To Java
    Replies: 2
    Last Post: 02-26-2011, 05:10 PM
  2. UnsatisfiedLinkError
    By leepan2008 in forum Advanced Java
    Replies: 4
    Last Post: 01-07-2011, 04:40 AM
  3. JNI: ava.lang.UnsatisfiedLinkError
    By tecno40 in forum Java Applets
    Replies: 0
    Last Post: 11-19-2010, 11:59 PM
  4. UnsatisfiedLinkError
    By Hussain Ali in forum Eclipse
    Replies: 2
    Last Post: 04-11-2010, 07:59 AM
  5. UnsatisfiedLinkError using gr.DotNetFromJava.cpp.dll
    By Viter_ in forum Advanced Java
    Replies: 0
    Last Post: 07-17-2009, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •