Jump to content

Trouble using external libraries (java.lang.NoClassDefFoundError)


Recommended Posts

Posted

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.

Posted
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.

Posted

@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?
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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