I just can't get Restlet on Android to work. I have the same jars, same generated classes etc. that I use in plain Java (it works there). Problem seems to be with the HttpClientHelper.

I also read this: http://wiki.restlet.org/docs_2.1/13-restlet/275-restlet/266-restlet.html.

Here's my code:

import netflix.catalog.v2.Genre;
import org.restlet.engine.Engine;
import org.restlet.ext.net.HttpClientHelper;
import org.restlet.ext.odata.Query;

        Engine.getInstance().getRegisteredClients().clear();
        Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null)); 

        SystemDataObjectsService service = new SystemDataObjectsService();  

        Query<Genre> query = service.createGenreQuery("/Genres");


        for (Genre g : query) {
            Log.d(TAG, g.getName());
        }

Here's the trace:

11-16 13:02:31.915: I/org.restlet(1344): Starting the HTTP client
11-16 13:02:31.924: I/org.restlet(1344): A recoverable error was detected (1001), attempting again in 2000 ms.
11-16 13:02:33.935: I/org.restlet(1344): A recoverable error was detected (1001), attempting again in 2000 ms.
11-16 13:02:35.955: E/org.restlet(1344): Can't get the metadata for http://odata.netflix.com/v2/Catalog/ (response's status: Communication Error (1001) - The connector failed to complete the communication with the server)
11-16 13:02:35.965: W/org.restlet(1344): Can't parse the content of http://odata.netflix.com/v2/Catalog/Genres
11-16 13:02:35.965: W/org.restlet(1344): java.lang.Exception: Can't execute the query without the service's metadata.
11-16 13:02:35.965: W/org.restlet(1344):    at org.restlet.ext.odata.Query.execute(Query.java:350)
11-16 13:02:35.965: W/org.restlet(1344):    at org.restlet.ext.odata.Query.iterator(Query.java:645)
11-16 13:02:35.965: W/org.restlet(1344):    at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:74)
11-16 13:02:35.965: W/org.restlet(1344):    at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:1)
11-16 13:02:35.965: W/org.restlet(1344):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
11-16 13:02:35.965: W/org.restlet(1344):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-16 13:02:35.965: W/org.restlet(1344):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-16 13:02:35.965: W/org.restlet(1344):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
11-16 13:02:35.965: W/org.restlet(1344):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-16 13:02:35.965: W/org.restlet(1344):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-16 13:02:35.965: W/org.restlet(1344):    at java.lang.Thread.run(Thread.java:856)
11-16 13:02:35.965: W/dalvikvm(1344): threadid=11: thread exiting with uncaught exception (group=0x409c01f8)

I also tried to import org.restlet.ext.httpclient.HttpClientHelper (and any other HttpClientHelper that Eclipse suggests) which lead to a slightly different trace:

11-16 13:06:27.775: I/org.restlet(1446): Get the metadata for http://odata.netflix.com/v2/Catalog/ at http://odata.netflix.com/v2/Catalog/$metadata
11-16 13:06:27.815: I/org.restlet(1446): Starting the HTTP client
11-16 13:06:27.836: W/org.restlet(1446): An error occurred during the communication with the remote HTTP server.
11-16 13:06:27.836: W/org.restlet(1446): java.net.UnknownHostException: Unable to resolve host "odata.netflix.com": No address associated with hostname
11-16 13:06:27.836: W/org.restlet(1446):    at java.net.InetAddress.lookupHostByName(InetAddress.java:400)
11-16 13:06:27.836: W/org.restlet(1446):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
11-16 13:06:27.836: W/org.restlet(1446):    at java.net.InetAddress.getAllByName(InetAddress.java:220)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-16 13:06:27.836: W/org.restlet(1446):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.ext.httpclient.internal.HttpMethodCall.sendRequest(HttpMethodCall.java:335)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.engine.http.adapter.ClientAdapter.commit(ClientAdapter.java:120)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.engine.http.HttpClientHelper.handle(HttpClientHelper.java:113)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.Client.handle(Client.java:180)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.resource.ClientResource.handle(ClientResource.java:944)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.resource.ClientResource.handle(ClientResource.java:912)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.resource.ClientResource.handle(ClientResource.java:867)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.resource.ClientResource.handle(ClientResource.java:892)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.resource.ClientResource.handle(ClientResource.java:801)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.resource.ClientResource.get(ClientResource.java:544)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.ext.odata.Service.getMetadata(Service.java:483)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.ext.odata.Query.<init>(Query.java:232)
11-16 13:06:27.836: W/org.restlet(1446):    at org.restlet.ext.odata.Service.createQuery(Service.java:277)
11-16 13:06:27.836: W/org.restlet(1446):    at net.ascorbin.locaspo.SystemDataObjectsService.createGenreQuery(SystemDataObjectsService.java:87)
11-16 13:06:27.836: W/org.restlet(1446):    at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:71)
11-16 13:06:27.836: W/org.restlet(1446):    at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:1)
11-16 13:06:27.836: W/org.restlet(1446):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
11-16 13:06:27.836: W/org.restlet(1446):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-16 13:06:27.836: W/org.restlet(1446):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-16 13:06:27.836: W/org.restlet(1446):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
11-16 13:06:27.836: W/org.restlet(1446):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-16 13:06:27.836: W/org.restlet(1446):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-16 13:06:27.836: W/org.restlet(1446):    at java.lang.Thread.run(Thread.java:856)
11-16 13:06:27.836: I/org.restlet(1446): A recoverable error was detected (1001), attempting again in 2000 ms.

I don't know what else to do, if someone has a running Restlet/ oData android project, perhaps he/ she can give me a hint?

share|improve this question
I have same issues. Found this link: stackoverflow.com/questions/6068303/android-restlet-https. Solution provided there didn't resolved my problems but maybe will help you... – cybevnm Nov 20 '12 at 18:08
Thanks, I tried that already. – Ascorbin Nov 24 '12 at 15:45
Can you post a reproducible code? – auselen Nov 26 '12 at 7:49
This looks like a DNS/IP connectivity issue. To be sure you could try to manually invoke Netflix OData service using the low level java.net.HttpURLConnection class – Jerome Louvel Nov 27 '12 at 7:25
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.