testrobot22 Posted November 30, 2019 Share Posted November 30, 2019 My custom made script doesn't start and the logger shows that some of my classes keep getting the message "Failed to load local script". I then pinpointed the exact problem to some async HTTP requests (both OkHttp and Unirest libraries). Synchronous requests work fine, but if I leave an async request in my code, the script will never be able to start and the logger will print that there is something wrong with the class that has the async method. What can I do to fix this? Quote Link to comment Share on other sites More sharing options...
Medusa Posted December 1, 2019 Share Posted December 1, 2019 Youneedtolinkcodeanderrors 1 Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 1, 2019 Author Share Posted December 1, 2019 (edited) 46 minutes ago, Medusa said: Youneedtolinkcodeanderrors Error in logger : [ERROR][12/01 10:34:28 AM]: Failed to load local script : com/osbot/jagex/AccountManager.class Β Code: Β import kong.unirest.HttpResponse; import kong.unirest.JsonNode; import kong.unirest.Unirest; import java.util.concurrent.CompletableFuture; public class AccountManager { public void registerAccount(String recaptchaResponse) { Unirest.post("http://www.google.com") .field("email", "xxxxx") .asJsonAsync(new Callback<JsonNode>() { @Override public void completed(HttpResponse<JsonNode> response) { System.out.println("xxx"); } @Override public void failed(UnirestException e) { e.printStackTrace(); cancelled(); } @Override public void cancelled() { System.out.println("login failed."); } }); } } Β As I said, if I replace this with a synchronous call I don't get that error. The same goes for both OkHttp and Unirest libs. Edited December 1, 2019 by testrobot22 Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 2, 2019 Author Share Posted December 2, 2019 (edited) Ugh, apparently, for some reason, OSBOT can't load this specific interface 'Callback', which is used for async calls. Does anyone have any idea why?? I'm using plenty of libs and everything else is working fine. Caused by: java.lang.NoClassDefFoundError: okhttp3/Callback Β Β Β at com.bot.osrs.gui.FXController.registerAccount(FXController.java:44) Β Β Β ... 57 more Caused by: java.lang.ClassNotFoundException: okhttp3.Callback Β Β Β at java.net.URLClassLoader.findClass(Unknown Source) Β Β Β at java.lang.ClassLoader.loadClass(Unknown Source) Β Β Β at java.lang.ClassLoader.loadClass(Unknown Source) Β Β Β ... 58 more Β EDIT: It seems it's actually a Kotlin file: Callback.kt, I presume Osbot doesn't support that? Β Edited December 2, 2019 by testrobot22 dddddddddd Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 2, 2019 Author Share Posted December 2, 2019 (edited) Why must I suffer.. lmao Caused by: java.security.AccessControlException: access denied ("java.net.NetPermission" "getProxySelector") Β Β Β at java.security.AccessControlContext.checkPermission(Unknown Source) Β Β Β at java.security.AccessController.checkPermission(Unknown Source) Β Β Β at java.lang.SecurityManager.checkPermission(Unknown Source) Β Β Β at org.osbot.Gb.checkPermission(mh:186) Β Β Β at java.net.ProxySelector.getDefault(Unknown Source) Β Β Β at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:167) Β Β Β at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:211) Β Edited December 2, 2019 by testrobot22 ddddddd Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 3, 2019 Author Share Posted December 3, 2019 So.. Uhh, can anyone help? Does OSBOT block getProxySelector? How can I send HTTP requests then? Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted December 3, 2019 Share Posted December 3, 2019 Is this for creating accounts on runescape? If so you could create this as a console app and create a bunch of accounts then dump them into a text file and have your script read from that text file. The file will have to be in the osbot data folder. I think thats the only location that scripts can read/write from. Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 4, 2019 Author Share Posted December 4, 2019 20 hours ago, BravoTaco said: Is this for creating accounts on runescape? If so you could create this as a console app and create a bunch of accounts then dump them into a text file and have your script read from that text file. The file will have to be in the osbot data folder. I think thats the only location that scripts can read/write from. Yes, it's for registering accounts. The idea was to have all in one solution, though, of course I can just make account registration a separate process. Then again, I imagine, that I would still need sometimes to use HTTP requests, for example, to check GE prices. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted December 5, 2019 Share Posted December 5, 2019 7 hours ago, testrobot22 said: Yes, it's for registering accounts. The idea was to have all in one solution, though, of course I can just make account registration a separate process. Then again, I imagine, that I would still need sometimes to use HTTP requests, for example, to check GE prices. For checking GE prices you can do it with HttpUrlConnection class. I once used it to compare github version vs the current script version. 1 Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 5, 2019 Author Share Posted December 5, 2019 15 hours ago, BravoTaco said: For checking GE prices you can do it with HttpUrlConnection class. I once used it to compare github version vs the current script version. Alright, Ill try that out. What kind of solution others are using? Quote Link to comment Share on other sites More sharing options...
testrobot22 Posted December 6, 2019 Author Share Posted December 6, 2019 Decided to go with HttpUrlConnection + multithreading 1 Quote Link to comment Share on other sites More sharing options...