title: How to use jersey client api in an android context?
body: <p>I´m trying to use my webservice via the jersey client api.
  This is my webservice:</p>
  
  <pre><code>@Path("/myresource")
  @Component
  @Scope("request")
  public class MyResource {
  
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  @Path("test")
  public String test(){
       return "test";
  } 
  </code></pre>
  
  <p>}</p>
  
  <p>This is my Client:</p>
  
  <pre><code>public class MyClient {
  public static void main(String[] args) {
   System.out.println(Client.create().resource( "http://testwebservice.de:8080/CompetenceNetwork/api/myresource/test" ).get( String.class ) );
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Everythings works fine. Now I try this in an android class:</p>
  
  <pre><code> TextView tv;
   public void onCreate(Bundle savedInstanceState)
   {
        super.onCreate(savedInstanceState);
        tv = new TextView(this);
        Client c = Client.create();
        WebResource r = c.resource("http://testwebservice.de:8080/CompetenceNetwork/api/myresource/test");
        String s = r.get(String.class);
        tv.setText(s);
        setContentView(tv);
     }
  </code></pre>
  
  <p>Nothing happends and after a few minutes I get the following exception:</p>
  
  <pre><code>11-04 17:13:27.382: ERROR/AndroidRuntime(231): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tablayout/com.example.tablayout.MyLogin}: com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: The operation timed out
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2335)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:648)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.widget.TabHost.setCurrentTab(TabHost.java:320)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:379)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.View.performClick(View.java:2364)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.View.onTouchEvent(View.java:4179)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.View.dispatchTouchEvent(View.java:3709)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:852)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.os.Handler.dispatchMessage(Handler.java:99)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.os.Looper.loop(Looper.java:123)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.ActivityThread.main(ActivityThread.java:4363)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at java.lang.reflect.Method.invokeNative(Native Method)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at java.lang.reflect.Method.invoke(Method.java:521)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at dalvik.system.NativeStart.main(Native Method)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): Caused by: com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: The operation timed out
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.sun.jersey.api.client.Client.handle(Client.java:616)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.sun.jersey.api.client.WebResource.handle(WebResource.java:559)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.sun.jersey.api.client.WebResource.get(WebResource.java:182)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at com.example.tablayout.MyLogin.onCreate(MyLogin.java:94)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): ... 31 more
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): Caused by: java.net.SocketException: The operation timed out
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.platform.OSNetworkSystem.connectSocketImpl(Native Method)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:114)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:245)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:535)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at java.net.Socket.connect(Socket.java:1054)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.&lt;init&gt;(HttpConnection.java:62)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:821)
  11-04 17:13:27.382: ERROR/AndroidRuntime(231): at org.apache.harmony.luni.internal.net.www.protocol.ht
  </code></pre>
  
  <p>I´m using target GoogleAPI 7 and the following jars:</p>
  
  <p>jersey-bundle-1.4.jar
  jsr311-api-1.1.jar
  junit-4.5.jar</p>
  
  <p>Does anybode has an idea to fix this?</p>
  
  <p>Greetings
  Christine Bauers</p>