Jump to content

Trouble using external libraries (java.lang.NoClassDefFoundError)


Auron

Recommended Posts

Hi,

I'm trying to use an extenal library to handle json parsing (in this case json-simple-1.1.1.jar)

This was all working for me fine about 10 months ago, but upon returning, it no longer works, I simply get 

java.lang.ClassNotFoundException: org.json.simple.parser.ParseException

I am using InetIliJ 2021.2.2 Community, and I have:

  • have added the jar as an External library
  • added the jar into the artifact ("Put into Output Root")
  • tried adding the library to a lib directory, and launching osbot using this directory as a classpath. E.G 
    • "C:\Program Files\Java\jre1.8.0_301\bin\java.exe" -cp "lib/*" org.osbot.Boot -debug

Does anybody have any ideas as to what I could be doing wrong? Has something changed in the last 10 months as to not allow external jars?

Thanks a lot!

This is essentially a duplicate of the thread below, but the solution does not work for me.

Link to comment
Share on other sites

12 hours ago, Gunman said:

@Auron Check the jar and see if the library was added into the script jar, if not then that's the problem. Worst case you can switch to GSON library that is built into the OSBot client.

@Gunman Thanks for the reply. Good shout, I forgot about looking in the jar. The jar certainly existed inside the script jar, but it still didn't work. However, I tried extracting the Jar into the output root and it works! (Although I could have sworn I tried that before...)

My solution 10 months ago was not putting the Jar in the artifact, but putting the jar on the classpath when running osbot. This is what seems to no longer work.

Thanks.

Link to comment
Share on other sites

@GunmanDamn, actually I think I've hit a wall here. I had another Jar I needed to add (mysql-connector-java), but if I try and extract that into my script jar, not only do I get a lot  of "Failed to load local script" for all the mysql classes, and when I try and run the script, I get 

java.lang.ExceptionInInitializerError
...
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")

I have a feeling there's no workaround for this - is there a way to connect to a local database? Or is the only solution here to create a proxy whereby you have to communicate with http requests or something?
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...