问题描述
我一直想如何解决我的问题了好几天,但我没有succeded。
我只是tyring执行的Restlet HTTPS请求。
在code是安静的简单,我只有一个acrivity:
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main); System.setProperty(假,java.net preferIPv6Addresses。); Engine.getInstance()getRegisteredClients()清()。
Engine.getInstance()getRegisteredClients()增加(新HttpsClientHelper(空))。 的System.out.println(VERIFICO IL权标:);
ClientResource clientResource =新ClientResource(
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=lalala); 再presentation代表= clientResource.get();
}
通过的Restlet给出的理由是:
产生的原因:通信错误(1001) - 错误在处理连接
所引发:
产生的原因:显示java.lang.NullPointerException
在org.apache.harmony.xnet.provider.jsse.ClientSessionContext$HostAndPort.hash$c$c(ClientSessionContext.java:214)
在java.util.HashMap.put(HashMap.java:393)
我在网上读到somewere这是一个Android的错误,但我无法找到任何解决办法
你知道吗?
我使用的Restlet 2.1 RC5
完整的堆栈跟踪是:
08-19 13:43:23.911:E / AndroidRuntime(30053):致命异常:主要
08-19 13:43:23.911:E / AndroidRuntime(30053):了java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.helloandroid / com.example.helloandroid.MainActivity}:通信错误(1001) - 错误在处理连接
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.ActivityThread.access $ 2300(ActivityThread.java:135)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2136)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.os.Handler.dispatchMessage(Handler.java:99)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.os.Looper.loop(Looper.java:144)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.ActivityThread.main(ActivityThread.java:4937)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.lang.reflect.Method.invokeNative(本机方法)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.lang.reflect.Method.invoke(Method.java:521)
08-19 13:43:23.911:E / AndroidRuntime(30053):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:858)
08-19 13:43:23.911:E / AndroidRuntime(30053):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-19 13:43:23.911:E / AndroidRuntime(30053):在dalvik.system.NativeStart.main(本机方法)
08-19 13:43:23.911:E / AndroidRuntime(30053):产生的原因:通信错误(1001) - 错误在处理连接
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.resource.ClientResource.doError(ClientResource.java:611)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.resource.ClientResource.handleInbound(ClientResource.java:1201)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.resource.ClientResource.handle(ClientResource.java:1068)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.resource.ClientResource.handle(ClientResource.java:1043)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.resource.ClientResource.handle(ClientResource.java:949)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.resource.ClientResource.get(ClientResource.java:657)
08-19 13:43:23.911:E / AndroidRuntime(30053):在com.example.helloandroid.MainActivity.onCreate(MainActivity.java:30)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
08-19 13:43:23.911:E / AndroidRuntime(30053):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
08-19 13:43:23.911:E / AndroidRuntime(30053):... 11个
08-19 13:43:23.911:E / AndroidRuntime(30053):致:显示java.lang.NullPointerException
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.apache.harmony.xnet.provider.jsse.ClientSessionContext$HostAndPort.hash$c$c(ClientSessionContext.java:214)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.util.HashMap.put(HashMap.java:393)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.apache.harmony.xnet.provider.jsse.ClientSessionContext.putSession(ClientSessionContext.java:190)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.apache.harmony.xnet.provider.jsse.ClientHandshakeImpl.unwrap(ClientHandshakeImpl.java:308)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.apache.harmony.xnet.provider.jsse.SSLRecordProtocol.unwrap(SSLRecordProtocol.java:413)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:478)
08-19 13:43:23.911:E / AndroidRuntime(30053):在javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.ext.ssl.internal.ReadableSslChannel.onDrain(ReadableSslChannel.java:114)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.io.Buffer.process(Buffer.java:553)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.io.Buffer.process(Buffer.java:668)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.io.ReadableBufferedChannel.read(ReadableBufferedChannel.java:172)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.io.Buffer.fill(Buffer.java:391)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.InboundWay.onFill(InboundWay.java:278)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.io.Buffer.process(Buffer.java:597)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.io.Buffer.process(Buffer.java:668)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.Way.processIoBuffer(Way.java:477)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.InboundWay.processIoBuffer(InboundWay.java:353)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.Way.onSelected(Way.java:430)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.ConnectionController.controlConnections(ConnectionController.java:105)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:156)
08-19 13:43:23.911:E / AndroidRuntime(30053):在org.restlet.engine.connector.Controller.run(Controller.java:158)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:441)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:561)
08-19 13:43:23.911:E / AndroidRuntime(30053):在java.lang.Thread.run(Thread.java:1102)
看来你是使用内部连接器的Restlet尽管您的来电:
Engine.getInstance()getRegisteredClients()清()。
Engine.getInstance()getRegisteredClients()增加(新HttpsClientHelper(空))。
您应该确保试试这个来代替:
Engine.getInstance()getRegisteredClients()清()。
Engine.getInstance()getRegisteredClients()增加(新org.restlet.ext.net.HttpClientHelper(空))。
I've been trying how to solve my problem for days but I didn't succeded.
I'm just tyring to perform RESTlet HTTPS request. The code is quiet simple as I've only one acrivity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.setProperty("java.net.preferIPv6Addresses", "false");
Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpsClientHelper(null));
System.out.println("VERIFICO IL TOKEN: ");
ClientResource clientResource = new ClientResource(
"https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=lalala");
Representation rep = clientResource.get();
}
The reason given by restlet is:
Caused by: Communication Error (1001) - Error while processing a connection
Caused By:
Caused by: java.lang.NullPointerException
at org.apache.harmony.xnet.provider.jsse.ClientSessionContext$HostAndPort.hashCode(ClientSessionContext.java:214)
at java.util.HashMap.put(HashMap.java:393)
I read somewere in the web it's an android bug but I couldn't find any workaround for that
Any idea?I'm using Restlet 2.1 RC5
The complete stacktrace is:
08-19 13:43:23.911: E/AndroidRuntime(30053): FATAL EXCEPTION: main
08-19 13:43:23.911: E/AndroidRuntime(30053): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.MainActivity}: Communication Error (1001) - Error while processing a connection
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.os.Handler.dispatchMessage(Handler.java:99)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.os.Looper.loop(Looper.java:144)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.ActivityThread.main(ActivityThread.java:4937)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.lang.reflect.Method.invokeNative(Native Method)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.lang.reflect.Method.invoke(Method.java:521)
08-19 13:43:23.911: E/AndroidRuntime(30053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
08-19 13:43:23.911: E/AndroidRuntime(30053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-19 13:43:23.911: E/AndroidRuntime(30053): at dalvik.system.NativeStart.main(Native Method)
08-19 13:43:23.911: E/AndroidRuntime(30053): Caused by: Communication Error (1001) - Error while processing a connection
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.resource.ClientResource.doError(ClientResource.java:611)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.resource.ClientResource.handleInbound(ClientResource.java:1201)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.resource.ClientResource.handle(ClientResource.java:1068)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.resource.ClientResource.handle(ClientResource.java:1043)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.resource.ClientResource.handle(ClientResource.java:949)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.resource.ClientResource.get(ClientResource.java:657)
08-19 13:43:23.911: E/AndroidRuntime(30053): at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:30)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
08-19 13:43:23.911: E/AndroidRuntime(30053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
08-19 13:43:23.911: E/AndroidRuntime(30053): ... 11 more
08-19 13:43:23.911: E/AndroidRuntime(30053): Caused by: java.lang.NullPointerException
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.apache.harmony.xnet.provider.jsse.ClientSessionContext$HostAndPort.hashCode(ClientSessionContext.java:214)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.util.HashMap.put(HashMap.java:393)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.apache.harmony.xnet.provider.jsse.ClientSessionContext.putSession(ClientSessionContext.java:190)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.apache.harmony.xnet.provider.jsse.ClientHandshakeImpl.unwrap(ClientHandshakeImpl.java:308)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.apache.harmony.xnet.provider.jsse.SSLRecordProtocol.unwrap(SSLRecordProtocol.java:413)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:478)
08-19 13:43:23.911: E/AndroidRuntime(30053): at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.ext.ssl.internal.ReadableSslChannel.onDrain(ReadableSslChannel.java:114)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.io.Buffer.process(Buffer.java:553)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.io.Buffer.process(Buffer.java:668)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.io.ReadableBufferedChannel.read(ReadableBufferedChannel.java:172)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.io.Buffer.fill(Buffer.java:391)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.InboundWay.onFill(InboundWay.java:278)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.io.Buffer.process(Buffer.java:597)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.io.Buffer.process(Buffer.java:668)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.Way.processIoBuffer(Way.java:477)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.InboundWay.processIoBuffer(InboundWay.java:353)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.Way.onSelected(Way.java:430)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.ConnectionController.controlConnections(ConnectionController.java:105)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:156)
08-19 13:43:23.911: E/AndroidRuntime(30053): at org.restlet.engine.connector.Controller.run(Controller.java:158)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
08-19 13:43:23.911: E/AndroidRuntime(30053): at java.lang.Thread.run(Thread.java:1102)
It seems that you are using the internal Restlet connector despite your call to:
Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpsClientHelper(null));
You should ensure try this instead:
Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new org.restlet.ext.net.HttpClientHelper(null));
这篇关于Android版的Restlet SSL空指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!