Hi,
I had an interface with a REST client that used to work on ARIS 7. Since moving to ARIS 9, nothing seems to be co-operating :(
When you run the script it gives this error without adding the Jersey JAR files (even though Jersey 1.1 files can be found in the std lib on the ARIS instance):
I then add the JAR files, but get this error:
I have included a script to show the code for you to test.
Test code:
try { var clientClass = Packages.com.sun.jersey.api.client.Client; var client = clientClass.create(); //The next line should work for password sites, not required for this example //client.addFilter(new com.sun.jersey.api.client.filter.HTTPBasicAuthFilter("user", "password")); var webResource = client.resource("http://jsonplaceholder.typicode.com/posts/1"); webResource.type("application/json"); /* tried this as well with same result var type = new javax.ws.rs.core.MediaType.APPLICATION_JSON; webResource.type(type); */ var response = webResource.get(Packages.com.sun.jersey.api.client.ClientResponse); var output = response.getEntity(String.class); var status = response.getStatus(); Dialogs.MsgBox(status + ": " + output); } catch(e) { Dialogs.MsgBox(e.toString()); }
Should result in JSON result (from a test website):
{ "userId": 1, "id": 1, "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" }
I have tried with the following scenarios with the same Initialisation error:
- With my own Java coded JAR files using Jersey
- Works in eclipse, but not in ARIS
- Tried using the latest version of Jersey 2.22.1
- Tried compiling with JDK 1.5, 1.6, 1.7 and 1.8
What am I missing?
I would appreciate any help :)
Thank you,
Francois Du Toit
cfdutoit@gmail.com
Hi Francois,
Your jar file must be added to the class path of Aris application.
I don't know exactly how to add it, but I think it is possible using the aris cloud controler. I don't know what is the command to to to write for this (maybe with "register app type") , but if someone from SAG knows how to do... I also need to do this.
If you have a solution, let me know it please.
Best Regards.
Hi Tricarico,
Thank you for the suggestion, I have tried loaading the jar into the lib folder, but it did not work. I develop using LOCAL, so I might have had the wong lib folder, because there are a few. Maybe SAG can guide me on where to go.
That said, when I create the script, I add the jar file in the same group as the script. I then include the jar in the script. So I get error 1 when no JAR is loaded, but get the second error on the sam code when the JARs has been loaded, so it seems to pick up something different. Don't know if that indicates a successul load without loading the JARs into the lib? I will ty it as well and revert with feedback later today.
Cheers,
Francois
Hi François,
That might be too late for your need (2 years ago) but I am adding this response in case some people are looking for some solution in your post.
I have been trying to do some java calls from the ARIS Javascript and I found an old post which explains everything.
http://www.ariscommunity.com/users/kylekatarn/2011-02-27-calling-java-code-report.
As reported by another user, you need to add the jar file in the folder "..\LOCALSERVER\jre\lib\ext". I have tested it with ARIS 9.8 and it works nicely.
I hope this will help any user coming to your post.
Regards,
Antonio