Jump to content

OSBot and HttpClient


Butters

Recommended Posts

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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.

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