DLL already loaded in another classloader

55 views
Skip to first unread message

TechnoRazor

unread,
Dec 21, 2019, 1:36:10 AM12/21/19
to netlogo-devel
I'm trying to make a NetLogo extension that loads in jar files. As of right now, I don't have much experience with this stuff, so I just added the jar files to the classpath along with the Netlogo jar. This seems to work until you try to reload the extension, which results in the "...dll already loaded in another classloader" error. I assume that's because the library is already loaded from the first time, but how would I avoid that? And if the answer is to not include them in the classpath, then how would I compile my code in the first place?
Again, I don't have much experience with this stuff, so please excuse and correct me if I use any incorrect terminology. I have no idea what to do from here, so any help is appreciated.

Michael Tamillow

unread,
Dec 21, 2019, 8:21:19 AM12/21/19
to TechnoRazor, netlogo-devel
Why are you reloading it? Can’t you just stop before that... you know, where everything works really well?

Sent from my iPhone

On Dec 21, 2019, at 12:31 AM, TechnoRazor <therealte...@gmail.com> wrote:

I'm not sure if this has been asked before, but I was unable to find the answer. Right now I have my own extension that requires a library I got from online. I don't have too much experience with using other libraries & making extensions and such, so please bear with me here. I wrote a .bat file to compile my code for me and put it into a .jar file, with the classpath including the NetLogo jar and the other libraries. I put my extension jar and the libraries in the extension folder, and everything seemed to be working really well. However, if you reload the extension, you get the "...dll already loaded in another classloader" error, which I assume happened because the library was already loaded.
Again, I don't know much about this stuff, so please excuse and correct me if I used the wrong terminology anywhere. I have no idea what to do from here, so any help is appreciated.

--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/1f3bbc22-f142-4a5d-9615-ca7b6db6766c%40googlegroups.com.

Charles

unread,
Dec 21, 2019, 12:55:58 PM12/21/19
to netlogo-devel
Many NetLogo extensions use third-party jar files, but I've never seen this error. Two questions:
  1. How are you reloading the extension?  From within NetLogo on the command line with the __reload primitive, or from within the NetLogo code itself?
  2. The message you get refers to a dll file.  Does one of the jar files call into a dll file?  If so, that can be a bit tricky.
Charles

TechnoRazor

unread,
Dec 21, 2019, 3:58:13 PM12/21/19
to netlogo-devel
When I say "reload", I mean simply removing the extension from the "extensions" in the code tab, then putting it back in. The same thing happens if you load one project that has the extension, then another project with the same extension.


On Saturday, December 21, 2019 at 8:21:19 AM UTC-5, Michael Tamillow wrote:
Why are you reloading it? Can’t you just stop before that... you know, where everything works really well?

Sent from my iPhone

On Dec 21, 2019, at 12:31 AM, TechnoRazor <therealte...@gmail.com> wrote:

I'm not sure if this has been asked before, but I was unable to find the answer. Right now I have my own extension that requires a library I got from online. I don't have too much experience with using other libraries & making extensions and such, so please bear with me here. I wrote a .bat file to compile my code for me and put it into a .jar file, with the classpath including the NetLogo jar and the other libraries. I put my extension jar and the libraries in the extension folder, and everything seemed to be working really well. However, if you reload the extension, you get the "...dll already loaded in another classloader" error, which I assume happened because the library was already loaded.
Again, I don't know much about this stuff, so please excuse and correct me if I used the wrong terminology anywhere. I have no idea what to do from here, so any help is appreciated.

--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlog...@googlegroups.com.

TechnoRazor

unread,
Dec 21, 2019, 3:59:53 PM12/21/19
to netlogo-devel
I answered the first question in my other reply. For the secon question, I'm using the "system hook" library as well as a couple of others, and the error is about the "...\AppData\Local\Temp\systemhook+1516139465.dll" file.

Seth Tisue

unread,
Dec 21, 2019, 5:59:37 PM12/21/19
to netlogo-devel
I wonder if there any examples of NetLogo extensions that use native libraries and successfully avoid this problem.

Perhaps the Arduino extension? The code in the unload() method at https://github.com/NetLogo/Arduino-Extension/blob/hexy/src/main/java/ArduinoExtension.java looks like it's intended to address this.

Seth

TechnoRazor

unread,
Dec 21, 2019, 9:35:43 PM12/21/19
to netlogo-devel
It worked perfectly, thanks! Could you please explain how it works, though? Thanks in advance

Seth Tisue

unread,
Dec 21, 2019, 10:16:08 PM12/21/19
to netlogo-devel
It's using reflection to call into some JVM internals that aren't declared `public`. Beyond that, I don't know.

Seth
Reply all
Reply to author
Forward
0 new messages