This is another META-INF/services issue - Jersey needs to know about
readers/writers, com.sun.jersey.core.impl.provider.entity.StringProvider
needs to be registered as MessageBodyReader.. which should be (according
to Buscador class). Can you debug it? Setting some breakpoints in
ServiceFinder and/or Buscador class should make everything clear.
Pavel
On 12/13/11 2:32 PM, takeshi honda wrote:
>> Thank you, Pavel.
>> I used Buscador class in the link you told me.
>> Then the NullPointerException disappeared but I got the following new
>> exception.
>> How can I fix this problem?
>> 12-13 22:21:37.367: INFO/study(14690):
>> com.sun.jersey.api.client.ClientHandlerException: A message body
>> reader for Java class java.lang.String, and Java type class
>> java.lang.String, and MIME media type text/html was not found
>> 12-13 22:21:37.367: INFO/study(14690): at
>> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:550)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:506)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> com.sun.jersey.api.client.WebResource.handle(WebResource.java:674)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> com.sun.jersey.api.client.WebResource.get(WebResource.java:191)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> jp.localhost.study.httpc.httpc.onCreate(httpc.java:45)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2674)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.app.ActivityThread.access$2300(ActivityThread.java:128)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.app.ActivityThread$H.handleMessage(ActivityThread.java:2074)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.os.Handler.dispatchMessage(Handler.java:99)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.os.Looper.loop(Looper.java:123)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> android.app.ActivityThread.main(ActivityThread.java:4680)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> java.lang.reflect.Method.invokeNative(Native Method)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> java.lang.reflect.Method.invoke(Method.java:521)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
>> 12-13 22:21:37.367: INFO/study(14690): at
>> dalvik.system.NativeStart.main(Native Method)
>>
>>> Hello,
>>>
>>> there is a problem with ServiceFinder on android platform, see
>>> this thread for workaround:
>>>
>>> http://jersey.576304.n2.nabble.com/java-lang-NullPointerException-on-Android-td4212447.html
>>>
>>> Regards,
>>> Pavel
>>>
>>> On 12/12/11 2:50 PM, takeshi honda wrote:
>>>
>>> CA+J_hrctSmePL4Zx4A_+tzc8-9pdW3Jz6wE42bvxYJEM6LkLiQ_at_mail.gmail.com
>>> <mailto:CA%2BJ_hrctSmePL4Zx4A_%2Btzc8-9pdW3Jz6wE42bvxYJEM6LkLiQ_at_mail.gmail.com>"
>>> type="cite">
>>> *Hi,*
>>> **
>>> *I'm trying to make http cilent with jersey1.10.*
>>> *I made an simple code as follows.*
>>> Client client = Client.create();
>>> WebResource wr = client.resource("http://www.yahoo.co.jp/
>>> <http://www.google.com/url?sa=D&q=http://www.yahoo.co.jp/&usg=AFQjCNH8Oq_RDLTkjGHXSm_BA4I_MPqjNg>");
>>> String result = wr.get(String.class); // NullPointerException
>>> But I got the following error.
>>> I use two jars.
>>> *jersey*-client-1.10.jar
>>> *jersey*-core-1.10.jar
>>> How can I fix this problem?
>>> java.lang.NullPointerException
>>> at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
>>> at
>>> com.sun.*jersey*.api.client.ClientResponse.getType(ClientResponse.java:
>>> 615)
>>> at
>>> com.sun.*jersey*.api.client.ClientResponse.getEntity(ClientResponse.java:
>>> 532)
>>> at
>>> com.sun.*jersey*.api.client.ClientResponse.getEntity(ClientResponse.java:
>>> 506)
>>> at
>>> com.sun.*jersey*.api.client.WebResource.handle(WebResource.java:
>>> 674)
>>> at
>>> com.sun.*jersey*.api.client.WebResource.get(WebResource.java:191)
>>> at jp.localhost.study.httpc.httpc.onCreate(httpc.java:41)
>>> at
>>> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
>>> 1047)
>>> at
>>> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
>>> 2674)
>>> at
>>> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
>>> 2726)
>>> at
>>> android.app.ActivityThread.access$2300(ActivityThread.java:128)
>>> at
>>> android.app.ActivityThread$H.handleMessage(ActivityThread.java:
>>> 2074)
>>> at android.os.Handler.dispatchMessage(Handler.java:99)
>>> at android.os.Looper.loop(Looper.java:123)
>>> at android.app.ActivityThread.main(ActivityThread.java:4680)
>>> at java.lang.reflect.Method.invokeNative(Native Method)
>>> at java.lang.reflect.Method.invoke(Method.java:521)
>>> at com.android.internal.os.ZygoteInit
>>> $MethodAndArgsCaller.run(ZygoteInit.java:858)
>>> at
>>> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
>>> at dalvik.system.NativeStart.main(Native Method)
>>>