2012-05-14 40 views
1

我正在使用restlet服務器爲我的移動應用程序提供了一個RESTful提供程序。是否有任何與清漆使用restlet工作?在varnish後面使用restlet時出錯(反向代理)

事實上,沒有使用清漆,使我的應用程序直接聯繫我的休息服務器一切正常。

這裏通過的Restlet服務器返回的異常:

May 14, 2012 7:48:10 PM org.restlet.resource.UniformResource doCatch 
WARNING: Exception or error caught in resource 
java.lang.NullPointerException 
     at fr.evoxmusic.ebackupserver.rest.IsGoogleRegistered.isGoogleRegistered(IsGoogleRegistered.java:30) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:597) 
     at org.restlet.resource.ServerResource.doHandle(ServerResource.java:449) 
     at org.restlet.resource.ServerResource.post(ServerResource.java:1114) 
     at org.restlet.resource.ServerResource.doHandle(ServerResource.java:533) 
     at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:590) 
     at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:302) 
     at org.restlet.resource.ServerResource.handle(ServerResource.java:849) 

注:我使用Reslet客戶端。在這裏我的代碼聯繫服務器。

​​

這裏是錯誤發生的isGoogleRegistered資源。

public class IsGoogleRegistered extends ServerResource { 

    /** 
    * Method used to verify if the token provided by the client is valid for 
    * the google server. 
    * 
    * @param entity as json representation 
    * @return a jsonobject containing the response 
    * @throws Exception 
    * 
    * @example : {"google":{"registrationid":"client token id"}} 
    */ 
    @Post("json") 
    public JsonRepresentation isGoogleRegistered(JsonRepresentation entity) throws Exception { 
     JSONObject wrapper = new JSONObject(); 
     JSONObject content = new JSONObject(); 

     wrapper = entity.getJsonObject().getJSONObject("google"); 

     try { 
      if (C2DMMessage.isGoogleRegistered(JBackupServer.c2dmToken, wrapper.getString("registrationid"))) 
       content.put("isgoogleregistered", true); 
      else 
       content.put("isgoogleregistered", false); 
     } catch (IOException e) { 
      content.put("error", "connection to google servers not available"); 
     } 

     wrapper = new JSONObject(); 
     wrapper.put("result", content); 

     JsonRepresentation jr = new JsonRepresentation(wrapper); 
     return jr; 
    } 

} 

線30:

wrapper = entity.getJsonObject().getJSONObject("google"); 

感謝。

回答

0

通過使用socat我看到清漆似乎不正確轉發分塊的HTTP請求傳遞給後臺..

+0

這裏的代碼,以防止使用的Restlet分塊HTTP請求。 ClientResource.setEntityBuffering(true); – eVoxmusic

相關問題