CrackplanetsCrac Posted October 11, 2018 Share Posted October 11, 2018 Hello people, First of all, let me appologise if this has clearly been answered multiple times, i searched all over the forum/google be was unable to really find anything that worked out for me. So i got a web api running on my server, this web api is connected with an sql server that is being hosted on my server as well. I can make calls to it and everything so i know it works. This led me to the point where it was time to implement it into my java scripts, and this is where i (with seemingly many others) hit the issue of using external libraries in or scrips. From reading all those posts it seems that they are just not allowed in the SDN, but that the usage of them localy should not be an issue. I run my stuff just localy, and don't touch the SDN at all (as far as im aware). That being said, the code has been written, the artifact has been build, but i am unable to run any of it and just spits out a whole list of errors "Failed to load local script: library class.class". I tried pretty much everything i was able to find, from adding modules, to extracted libraries in my artifacts, but i seem to be unable to add them, or atleast get Osbot from running the script For this reason i would like to ask the question if anyone here 'that has used excternal libraries in local scrips before' could give me a rundown as to how its done. For those that are intrested the libraries that i am trying to include are Retrofit2, Okhttp3 and retrofits Gson Converter factory. I got them all as jar files, that being said they are all open source, so i could get my hands on the source files if that needed to get it to work. Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted October 11, 2018 Share Posted October 11, 2018 I might be wrong, but I don't think osbot supports external libraries. Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 Thought that went only for scripts that would be uploaded to the SDN? From wat i gathered by reading posts, there are ways to do it when its just local scrips? Quote Link to comment Share on other sites More sharing options...
Explv Posted October 11, 2018 Share Posted October 11, 2018 @CrackplanetsCrac Firstly you _can_ use external libraries on the SDN, you will just need to include the source of those libraries in your repository. As for local scripts, have you tried extracting the dependency to your output .jar? Example: Here you can see the library you want to add in the Available Elements section on the right hand side Right click the library and select extract into output root Now the extracted library will be output to your .jar And it should work when running your script 2 Quote Link to comment Share on other sites More sharing options...
liverare Posted October 11, 2018 Share Posted October 11, 2018 Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 (edited) @Explv So i got that, and it compiles nicely, i then run osbot through cmd like java -jar "path/to/osbot/jar" -debug sadly enough when then checking the script tab the out put it generates gives me alot of complains Spoiler [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$ChunkedSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/cache/DiskLruCache$2.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/cache/DiskLruCache$Editor$1.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http2/Http2Codec$StreamFinishingSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$FixedLengthSink.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http/CallServerInterceptor$CountingSink.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$AbstractSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/ws/WebSocketWriter$FrameSink.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/cache/FaultHidingSink.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$FramingSink.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/cache2/Relay$RelaySource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/Cache$CacheResponseBody$1.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$FixedLengthSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$UnknownLengthSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$FramingSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$StreamTimeout.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$ChunkedSink.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/http2/Http2Reader$ContinuationSource.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/Cache$CacheRequestImpl$1.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : okhttp3/internal/cache/CacheInterceptor$1.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : retrofit2/OkHttpCall$ExceptionCatchingRequestBody$1.class [ERROR][10/11 08:55:38 PM]: Failed to load local script : org/apache/commons/logging/impl/ServletContextCleaner.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter$ReverseEngineeredCallbackFilter.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$ChunkedSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/cache/DiskLruCache$2.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/cache/DiskLruCache$Editor$1.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http2/Http2Codec$StreamFinishingSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$FixedLengthSink.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http/CallServerInterceptor$CountingSink.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$AbstractSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/ws/WebSocketWriter$FrameSink.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/cache/FaultHidingSink.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$FramingSink.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/cache2/Relay$RelaySource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/Cache$CacheResponseBody$1.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$FixedLengthSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$UnknownLengthSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$FramingSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$StreamTimeout.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$ChunkedSink.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/http2/Http2Reader$ContinuationSource.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/Cache$CacheRequestImpl$1.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : okhttp3/internal/cache/CacheInterceptor$1.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : retrofit2/OkHttpCall$ExceptionCatchingRequestBody$1.class [ERROR][10/11 08:55:39 PM]: Failed to load local script : org/apache/commons/logging/impl/ServletContextCleaner.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter$ReverseEngineeredCallbackFilter.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$ChunkedSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/cache/DiskLruCache$2.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/cache/DiskLruCache$Editor$1.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http2/Http2Codec$StreamFinishingSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$FixedLengthSink.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http/CallServerInterceptor$CountingSink.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$AbstractSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/ws/WebSocketWriter$FrameSink.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/cache/FaultHidingSink.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$FramingSink.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/cache2/Relay$RelaySource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/Cache$CacheResponseBody$1.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$FixedLengthSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$UnknownLengthSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$FramingSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http2/Http2Stream$StreamTimeout.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http1/Http1Codec$ChunkedSink.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/http2/Http2Reader$ContinuationSource.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/Cache$CacheRequestImpl$1.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : okhttp3/internal/cache/CacheInterceptor$1.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : retrofit2/OkHttpCall$ExceptionCatchingRequestBody$1.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : org/apache/commons/logging/impl/ServletContextCleaner.class [ERROR][10/11 08:55:40 PM]: Failed to load local script : com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter$ReverseEngineeredCallbackFilter.class If i then try to run it regardless it throws me an uncaught exception Spoiler [ERROR][10/11 09:00:21 PM]: Uncaught exception! java.lang.NoClassDefFoundError: okio/Sink at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:453) at ApiTest.onStart(ApiTest.java:23) at org.osbot.rs07.event.ScriptExecutor.iiiIIiiiiIIi(fo:194) at org.osbot.rs07.event.ScriptExecutor.start(fo:99) at org.osbot.Ib.run(uq:141) 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: okio.Sink at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 8 more So i must be doing something wrong, but not sure wat that might be, pretty sure mine looks the same likes yours for the rest ps: this is currently just a siomple test script, that makes a call tot he github api, lines 23 is nothing but the BaseUrl that its suppose to connect with ( "https://api.github.com/" ) @liverare Trying your after i get back from the store (quickly before it closes) thanks in advance, Edited October 11, 2018 by CrackplanetsCrac Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 @liverare I quickly tried it (couldn't help myself) I got a folder on the dekstop called OsBot-api inthere a folder called lib and a bat file containing java -cp "lib/*" org.osbot.Boot -debug and then in the lib folder all the jar's including osbot But whenever i run the command it throws and error at me Error: Could not find or load main class org.osbot.Boot Neither when i point it directly to my java install. Quote Link to comment Share on other sites More sharing options...
jca Posted October 11, 2018 Share Posted October 11, 2018 42 minutes ago, CrackplanetsCrac said: @liverare I quickly tried it (couldn't help myself) I got a folder on the dekstop called OsBot-api inthere a folder called lib and a bat file containing java -cp "lib/*" org.osbot.Boot -debug and then in the lib folder all the jar's including osbot But whenever i run the command it throws and error at me Error: Could not find or load main class org.osbot.Boot Neither when i point it directly to my java install. Why don’t you just use HttpURLConnection and if the response is JSON use Gson parser? A lot simple than all the dependencies Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 29 minutes ago, jca said: Why don’t you just use HttpURLConnection and if the response is JSON use Gson parser? A lot simple than all the dependencies Just alot more experiance using these, but as it look now its gonna end up being the way that you are sugesting. Just a shame, beccause this would also allow for more then just this, if i ever end up needing something else, then i still won't be able to do it, so kinda hoped i would find a working solution regardless. Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 After some more testing i did get to start my client by doing wat @liverare suggested i did get my script to work, it nicely boots the osbot client, but once i then try and run a script that makes use of the library's i still get the errors Spoiler [ERROR][10/11 10:44:39 PM]: Uncaught exception! java.lang.NoClassDefFoundError: okio/Sink at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:453) at ApiTest.onStart(ApiTest.java:23) at org.osbot.rs07.event.ScriptExecutor.iiiIIiiiiIIi(fo:194) at org.osbot.rs07.event.ScriptExecutor.start(fo:99) at org.osbot.Ib.run(uq:141) 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: okio.Sink at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 8 more And alot more then i am willing to show (100's of lines of errors, basicly just one for every class) Quote Link to comment Share on other sites More sharing options...
jca Posted October 11, 2018 Share Posted October 11, 2018 13 minutes ago, CrackplanetsCrac said: Just alot more experiance using these, but as it look now its gonna end up being the way that you are sugesting. Just a shame, beccause this would also allow for more then just this, if i ever end up needing something else, then i still won't be able to do it, so kinda hoped i would find a working solution regardless. What more are you thinking? There’s always a solution! Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 55 minutes ago, jca said: What more are you thinking? There’s always a solution! Rxjava, maybe jackson, or log4j. I know that for alot of them there are default once, but those libraries are often easyer, quicker or just cleaner. And i like to be able to just use them when ever. Hell even doubtfull now if maven would even work. Quote Link to comment Share on other sites More sharing options...
liverare Posted October 11, 2018 Share Posted October 11, 2018 If I had to take a guess, the problem could either be: The batch file isn't loading all of the jar files in the /lib/ folder. I believe "lib/*" statement in the batch file would grab them all, but I could be wrong. The jar files aren't being included as dependencies when you compile your scripts. I might take a look into this tomorrow. Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 23 minutes ago, liverare said: If I had to take a guess, the problem could either be: The batch file isn't loading all of the jar files in the /lib/ folder. I believe "lib/*" statement in the batch file would grab them all, but I could be wrong. The jar files aren't being included as dependencies when you compile your scripts. I might take a look into this tomorrow. Thanks for taking the time! After some more testing i noticed that some kotlin files are needed that i did not include. Trying to find out where to download those now, my issue with your way of doing it might not be the method, but rather me missing a jar in my lib. I let you know once i know more. Quick side note, any clue if this would work with maven projects? it would take alot of manual jars out of my hands. Quote Link to comment Share on other sites More sharing options...
CrackplanetsCrac Posted October 11, 2018 Author Share Posted October 11, 2018 Got it to work in the end, but instantly got greeted with a Blocked permission message. Quote Link to comment Share on other sites More sharing options...