2013-01-08 104 views
2

我有一個Restlet服務器應用程序,用於調用客戶端資源以達到Google端點的目的。從服務器資源調用Restlet客戶端資源導致HTTP 404錯誤

當我在我的代碼點:

ClientResource storeRoot = new ClientResource("http://googleendpoint"); 
    String jsonString = storeRoot.get().getText(); 

我得到的警告和錯誤:

2013年1月7日下午4點33分34秒org.restlet.engine。 component.ClientRouter getNext警告:此請求使用的協議未在 客戶端連接器列表中聲明。 (HTTPS/1.1)。如果您正在使用Component類的 實例,請檢查其「客戶」屬性。不 找到(404) - 服務器沒有找到任何匹配的請求URI 在 org.restlet.resource.ClientResource.doError(ClientResource.java:612)

我用Google搜索周圍,可見,解決方案是有可能加入該協議的端點是這樣的:

component.getClients​().add(Protocol.HTTPS​); 

的問題是,我運行這個在tomcat的war文件。我在哪裏可以訪問這個組件對象來添加協議?

我也改變了我的web.xml中支持此協議是這樣的:

<?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> 
+1

在構建我的應用程序的某一點我有這樣的問題,通過添加以下到我的web.xml固定它:[代碼] <的context-param> \t \t​​org.restlet.clients \t \t <! - CLAP FILE - > \t \t CLAP HTTP HTTPS \t [代碼] –

回答

2

很多心痛之後,我確定的解決方案是在以上安迪也表示增加以下罐子的web.xml中加入則params的:

org.restlet.ext.net 組織。 restlet.ext.httpclient org.restlet.ext.ssl

4

嘗試添加下列到你的web.xml中,<servlet>元素中。

<!-- Your application class name --> 
<init-param> 
    <param-name>org.restlet.application</param-name> 
    <param-value>test.MyApplication</param-value> 
</init-param> 

<!-- List of supported client protocols --> 
<init-param> 
    <param-name>org.restlet.clients</param-name> 
    <param-value>HTTP HTTPS FILE</param-value> 
</init-param> 

的更完整的文檔見http://www.restlet.org/documentation/snapshot/gae/ext/org/restlet/ext/servlet/ServerServlet.html

+0

我已經加入這個web.xml中但我在上面的錯誤中沒有看到任何更改。還有什麼我可以嘗試嗎? – Atma

+0

如果您有 com.MyApplication 需要您的類的完整程序包名稱從org.restlet.Application派生(我假設它不是真的稱爲「com.MyApplication 「, 是嗎?)。 –

相關問題