Jump to content

OSBot and HttpClient


Recommended Posts

Posted

Hello,

Having troubles when running HttpClient within osbot. Is it even allowed? Doesn't throw any security exceptions. Using same logic and etc outside OSBot.

Using: httpclient-osgi-4.3.jar (works outside of OSBot). Tried other versions as well. Added this to classpath of course.

Using when in onStart():

HttpClient client = new DefaultHttpClient();

Error:

[INFO][09/19 09:46:54 AM]: Started bot #1
Starting script...
Loaded 18 local scripts and 63 SDN scripts.
[ERROR][09/19 09:46:57 AM]: Uncaught exception!
java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient

        at java.lang.Class.getDeclaredConstructors0(Native Method)

        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)

        at java.lang.Class.getConstructor0(Unknown Source)

        at java.lang.Class.getConstructor(Unknown Source)

        at org.osbot.Xb.run(um:268)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassNotFoundException: org.apache.http.client.HttpClient

        at java.net.URLClassLoader.findClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        ... 8 more

 

Posted

Just start with the basics, learn how to read a stack trace because it's very important when debugging. You received an error but immediately assumed it was an OSBot error. The stack trace clearly told you what the problem was, so you should work from there. Polymorphism pretty much gave you the answer.

 

The error:

https://docs.oracle.com/javase/7/docs/api/java/lang/NoClassDefFoundError.html

  • Like 1
Posted

Thank you for the heads up, appreciate it.

1 hour ago, Polymorphism said:

Try adding the source to your project instead of linking the dependency. This should also allow it on the SDN, as long as Alek doesn't say no to it. 

 

http://hc.apache.org/downloads.cgi

Regarding this. I have two noobish questions:

1) Apart from SDN, why shouldn't it work if I add all the mentioned jars to the build path in Eclipse? During script export all is well and no errors. Clearly the class in question isn't found at runtime.

2) Actually ashamed to ask this but how do you import the source code for this properly? Put everything by hand to correct packages/folders where the classes expect they would be? Cause tried importing the source in various ways and failed.

Posted
5 hours ago, nosepicker said:

Thank you for the heads up, appreciate it.

Regarding this. I have two noobish questions:

1) Apart from SDN, why shouldn't it work if I add all the mentioned jars to the build path in Eclipse? During script export all is well and no errors. Clearly the class in question isn't found at runtime.

2) Actually ashamed to ask this but how do you import the source code for this properly? Put everything by hand to correct packages/folders where the classes expect they would be? Cause tried importing the source in various ways and failed.

1) I personally try not to use libraries is non-runnable jar files. I'm not 100% positive on this, but maybe classes aren't being extracted from the library since the script isn't "runnable"

 

2) I believe there are other components which are dependencies of HttpComponents, their website should mention which ones. Download the source and put the extracted files in /src 

Posted
12 hours ago, Polymorphism said:

1) I personally try not to use libraries is non-runnable jar files. I'm not 100% positive on this, but maybe classes aren't being extracted from the library since the script isn't "runnable"

 

2) I believe there are other components which are dependencies of HttpComponents, their website should mention which ones. Download the source and put the extracted files in /src 

Yep, there are dependencies for http components, all of which are included and tested outside OSBot. As I understood from Alek, OSBot is ok with this, I'm just not doing this properly.

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