I have a Restlet server application that calls client resource for the purpose of hitting a google endpoint.
When I get to the point in my code:
ClientResource storeRoot = new ClientResource("http://googleendpoint");
String jsonString = storeRoot.get().getText();
I get the warnings and errors:
Jan 7, 2013 4:33:34 PM org.restlet.engine.component.ClientRouter getNext WARNING: The protocol used by this request is not declared in the list of client connectors. (HTTPS/1.1). In case you are using an instance of the Component class, check its "clients" property. Not Found (404) - The server has not found anything matching the request URI at org.restlet.resource.ClientResource.doError(ClientResource.java:612)
I have googled around and seen that the solution is likely adding the protocol to the endpoint like this:
component.getClients().add(Protocol.HTTPS);
The problem is that I am running this as a war file in tomcat. Where do I access this component object to add the protocol?
I have also changed my web.xml to support this protocol like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Restlet adapters</display-name>
<servlet>
<servlet-name>Restlet1</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
<init-param>
<param-name>org.restlet.application</param-name>
<param-value>com.MyApplication</param-value>
</init-param>
<init-param>
<param-name>org.restlet.clients</param-name>
<param-value>HTTP HTTPS FILE</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Restlet1</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
After a lot of heartache I determined that solution was the addition of params in the web.xml that Andy stated above and also the addition of the following jars:
org.restlet.ext.net org.restlet.ext.httpclient org.restlet.ext.ssl