Hi Santiago,
it seems the JAX-RS RuntimeDelegate instance does not initialize correctly.
The line, where the exception is thrown is:
return delegate.fromString(type);
where the delegate property should get initialized when the MediaType class
is loaded:
private static final HeaderDelegate<MediaType> delegate =
RuntimeDelegate.getInstance().createHeaderDelegate(MediaType.class);
the getInstance method above relies on the mechanism described in the
JAX-RS specification [1].
You can try to manually inject the RD instance (see [2]), before you try
to invoke
the client, like follows:
RuntimeDelegate.setInstance(new com.sun.ws.rs.ext.RuntimeDelegateImpl());
the above should get invoked anyway as part of JAX-RS RD lookup,
but it is not clear, if the lookup happens at all.
Does it help?
~Jakub
[1]
http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-650007
[2]
http://jsr311.java.net/nonav/releases/1.1/javax/ws/rs/ext/RuntimeDelegate.html#setInstance%28javax.ws.rs.ext.RuntimeDelegate%29
On 07/15/2011 02:42 AM, santiago carrillo wrote:
> Hi there,
>
> I am trying to use Jersey in an Android app to call service running on
> a server
> VM Ware vFabric provided by the Srping Source Tool Suite.
>
>
> Is there any api to or way to used it because is not working properly,
> I am gettin the expeption while calling it:
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319):
> java.lang.NullPointerException
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> com.sun.jersey.api.client.PartialRequestBuilder.type(PartialRequestBuilder.java:92)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> com.sun.jersey.api.client.WebResource.type(WebResource.java:304)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> com.test.RestTestActivity.onClick(RestTestActivity.java:40)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> android.view.View.performClick(View.java:2408)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> android.view.View$PerformClick.run(View.java:8816)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> android.os.Handler.handleCallback(Handler.java:587)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> android.os.Handler.dispatchMessage(Handler.java:92)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> android.os.Looper.loop(Looper.java:123)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> android.app.ActivityThread.main(ActivityThread.java:4627)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> java.lang.reflect.Method.invokeNative(Native Method)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> java.lang.reflect.Method.invoke(Method.java:521)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
> 07-15 00:34:27.734: ERROR/AndroidRuntime(319): at
> dalvik.system.NativeStart.main(Native Method)
>
>
>
> Thanks a lot
>
> --
>
>
>
>
> Santiago Carrillo
>