android:http 使用SDK4.0.3之后的线程错误问题

原文链接:https://yq.aliyun.com/articles/380611

今天突然发现了一个问题,就是之前使用org.apache.http load数据的时候突然报错,找了许久原因,原来是SDK的问题。之前http的操作可参照android:http 。经测试,使用在使用4.0.3的SDK然后在4.0以上的机子运行时就会报错。报的错误是关于主线程的错误。然后把load的操作加上异步之后,就没有问题了。看来,google在4.0.3之后加了限制,http的操作只能异步操作了!


本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/07/27/2612049.html,如需转载请自行联系原作者

展开阅读全文
博主设置当前文章不允许评论。

HTTP Status 500错误问题

05-26

HTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: Unable to compile class for JSPrnrnAn error occurred at line: 14 in the jsp file: /index.jsprnGenerated servlet error:rnsSystem.out cannot be resolved to a typernrnrnorg.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)rnorg.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)rnorg.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)rnorg.apache.jasper.compiler.Compiler.compile(Compiler.java:297)rnorg.apache.jasper.compiler.Compiler.compile(Compiler.java:276)rnorg.apache.jasper.compiler.Compiler.compile(Compiler.java:264)rnorg.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)rnorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)rnorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rnorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rnjavax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/5.5.15 论坛

关于android http协议请求错误问题

05-06

由于是android小白,按照网上给的源码学习了一下向百度获取网页信息的代码,但是在发送请求的时候虚拟机没有相应。。。rn下面是源代码及logcat输出日志rn//MainActivity.classrnpackage org.marsdroid.http01;rnrnimport java.io.BufferedReader;rnimport java.io.InputStream;rnimport java.io.InputStreamReader;rnrnimport org.apache.http.HttpEntity;rnimport org.apache.http.HttpResponse;rnimport org.apache.http.client.HttpClient;rnimport org.apache.http.client.methods.HttpGet;rnimport org.apache.http.impl.client.DefaultHttpClient;rnrnimport android.app.Activity;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnrnpublic class MainActivity extends Activity rn private Button requestButton = null;rn private HttpResponse httpResponse = null;rn private HttpEntity httpEntity = null;rn /** Called when the activity is first created. */rn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.main);rn rn requestButton = (Button)findViewById(R.id.requestButton);rn requestButton.setOnClickListener(new OnClickListener() rn rn @Overridern public void onClick(View v) rn rn HttpGet httpGet = new HttpGet("http://www.baidu.com");rn rn HttpClient httpClient = new DefaultHttpClient();rn rn InputStream inputStream = null;rn try rn httpResponse = httpClient.execute(httpGet);rn httpEntity = httpResponse.getEntity();rn inputStream = httpEntity.getContent();rn BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));rn String result = "";rn String line = "";rn while((line = reader.readLine()) != null)rn result = result + line;rn rn System.out.println(result);rn catch (Exception e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn finallyrn tryrn inputStream.close();rn rn catch(Exception e)rn e.printStackTrace();rn rn rn rn );rn rnrnrnlogcat日志rn[img=https://img-bbs.csdn.net/upload/201405/06/1399362413_559286.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201405/06/1399362428_797030.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201405/06/1399362513_464716.jpg][/img]rnrn还望大神能帮忙解决一下问题 论坛

HTTP 500错误问题怎么解决?

06-27

环境:win2000+jdk1.6.06+Apache Tomcat 6.0.16 + accessrn开发:eclipse 3.3rn问题:HTTP 500rn详细描述:rn通过eclipse启动TOMCAT,什么事都没有。但通过TOMCAT 控制台TOMCAT时,其它都正常,就是JSP连数据库时报 HTTP STATUS 500.rntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: java.lang.NullPointerExceptionrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnrnjava.lang.NullPointerExceptionrn bocbi.jdbcUtil.initDBS(jdbcUtil.java:262)rn bocbi.jdbcUtil.xml2table(jdbcUtil.java:182)rn org.apache.jsp.download_jsp._jspService(download_jsp.java:81)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.rnrnrn--------------------------------------------------------------------------------rn 论坛

android 日志错误问题

03-02

调试android遇到这个问题,麻烦高手看看rn下面是日志文件:rn03-02 10:15:57.211: I/UserinfoService(13435): initsucrn03-02 10:15:57.241: W/System.err(13435): java.net.SocketException: Bad socketrn03-02 10:15:57.241: W/System.err(13435): at org.apache.harmony.luni.platform.OSNetworkSystem.sendStreamImpl(Native Method)rn03-02 10:15:57.241: W/System.err(13435): at org.apache.harmony.luni.platform.OSNetworkSystem.sendStream(OSNetworkSystem.java:498)rn03-02 10:15:57.241: W/System.err(13435): at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:585)rn03-02 10:15:57.241: W/System.err(13435): at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59)rn03-02 10:15:57.241: W/System.err(13435): at java.io.DataOutputStream.write(DataOutputStream.java:101)rn03-02 10:15:57.251: W/System.err(13435): at java.io.FilterOutputStream.write(FilterOutputStream.java:94)rn03-02 10:15:57.261: W/System.err(13435): at com.nenglong.jxpt.client.transport.Connector.write(Connector.java:168)rn03-02 10:15:57.281: W/System.err(13435): at com.nenglong.jxpt.client.transport.Transport.send(Transport.java:74)rn03-02 10:15:57.281: W/System.err(13435): at com.nenglong.jxpt.client.transport.Transport.submit(Transport.java:46)rn03-02 10:15:57.281: W/System.err(13435): at com.nenglong.jxpt.client.service.offlinemessage.OfflineMSGService.getOfflineMSG(OfflineMSGService.java:54)rn03-02 10:15:57.281: W/System.err(13435): at com.nenglong.jxpt.client.activity.system.LoginActivity$4.run(LoginActivity.java:282)rn03-02 10:15:57.301: W/System.err(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.321: E/error(13435): Bad socketrn03-02 10:15:57.321: E/error(13435): java.net.SocketException: Bad socketrn03-02 10:15:57.321: E/error(13435): at org.apache.harmony.luni.platform.OSNetworkSystem.sendStreamImpl(Native Method)rn03-02 10:15:57.321: E/error(13435): at org.apache.harmony.luni.platform.OSNetworkSystem.sendStream(OSNetworkSystem.java:498)rn03-02 10:15:57.321: E/error(13435): at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:585)rn03-02 10:15:57.321: E/error(13435): at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59)rn03-02 10:15:57.321: E/error(13435): at java.io.DataOutputStream.write(DataOutputStream.java:101)rn03-02 10:15:57.321: E/error(13435): at java.io.FilterOutputStream.write(FilterOutputStream.java:94)rn03-02 10:15:57.321: E/error(13435): at com.nenglong.jxpt.client.transport.Connector.write(Connector.java:168)rn03-02 10:15:57.321: E/error(13435): at com.nenglong.jxpt.client.transport.Transport.send(Transport.java:74)rn03-02 10:15:57.321: E/error(13435): at com.nenglong.jxpt.client.transport.Transport.submit(Transport.java:46)rn03-02 10:15:57.321: E/error(13435): at com.nenglong.jxpt.client.service.offlinemessage.OfflineMSGService.getOfflineMSG(OfflineMSGService.java:54)rn03-02 10:15:57.321: E/error(13435): at com.nenglong.jxpt.client.activity.system.LoginActivity$4.run(LoginActivity.java:282)rn03-02 10:15:57.321: E/error(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.351: W/System.err(13435): java.net.SocketException: Socket input is shutdownrn03-02 10:15:57.351: W/System.err(13435): at java.net.Socket.shutdownInput(Socket.java:815)rn03-02 10:15:57.371: W/System.err(13435): at com.nenglong.jxpt.client.transport.Connector.close(Connector.java:137)rn03-02 10:15:57.381: W/System.err(13435): at com.nenglong.jxpt.client.transport.Transport.send(Transport.java:80)rn03-02 10:15:57.392: W/System.err(13435): at com.nenglong.jxpt.client.transport.Transport.submit(Transport.java:46)rn03-02 10:15:57.392: W/System.err(13435): at com.nenglong.jxpt.client.service.offlinemessage.OfflineMSGService.getOfflineMSG(OfflineMSGService.java:54)rn03-02 10:15:57.392: W/System.err(13435): at com.nenglong.jxpt.client.activity.system.LoginActivity$4.run(LoginActivity.java:282)rn[color=#FF0000]03-02 10:15:57.392: W/System.err(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.401: I/ddd(13435): -------0rn03-02 10:15:57.401: D/AndroidRuntime(13435): Shutting down VMrn03-02 10:15:57.401: W/dalvikvm(13435): threadid=3: thread exiting with uncaught exception (group=0x4001b188)rn03-02 10:15:57.401: E/AndroidRuntime(13435): Uncaught handler: thread main exiting due to uncaught exceptionrn03-02 10:15:57.401: E/AndroidRuntime(13435): java.lang.NullPointerExceptionrn03-02 10:15:57.401: E/AndroidRuntime(13435): at com.nenglong.jxpt.client.util.Utils.error(Utils.java:636)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at com.nenglong.jxpt.client.service.BaseService$1.handleMessage(BaseService.java:35)rn03-02 10:15[/color]:57.401: E/AndroidRuntime(13435): at android.os.Handler.dispatchMessage(Handler.java:99)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at android.os.Looper.loop(Looper.java:123)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at android.app.ActivityThread.main(ActivityThread.java:4363)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at java.lang.reflect.Method.invokeNative(Native Method)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at java.lang.reflect.Method.invoke(Method.java:521)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)rn03-02 10:15:57.401: E/AndroidRuntime(13435): at dalvik.system.NativeStart.main(Native Method)rn03-02 10:15:57.401: I/dalvikvm(13435): threadid=7: reacting to signal 3rn03-02 10:15:57.444: E/dalvikvm(13435): Unable to open stack trace file '/data/anr/traces.txt': Permission deniedrn03-02 10:15:57.444: E/SMSService(13435): nullrn03-02 10:15:57.444: E/SMSService(13435): java.lang.NullPointerExceptionrn03-02 10:15:57.444: E/SMSService(13435): at com.nenglong.jxpt.client.command.BaseCommand.(BaseCommand.java:67)rn03-02 10:15:57.444: E/SMSService(13435): at com.nenglong.jxpt.client.command.offlinemessage.OfflineMsgCommand.(OfflineMsgCommand.java:25)rn03-02 10:15:57.444: E/SMSService(13435): at com.nenglong.jxpt.client.service.offlinemessage.OfflineMSGService.getOfflineMSG(OfflineMSGService.java:56)rn03-02 10:15:57.444: E/SMSService(13435): at com.nenglong.jxpt.client.activity.system.LoginActivity$4.run(LoginActivity.java:282)rn03-02 10:15:57.444: E/SMSService(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.451: E/LoginActivity(13435): nullrn03-02 10:15:57.451: E/LoginActivity(13435): java.lang.NullPointerExceptionrn03-02 10:15:57.451: E/LoginActivity(13435): at com.nenglong.jxpt.client.activity.system.LoginActivity$4.run(LoginActivity.java:286)rn03-02 10:15:57.451: E/LoginActivity(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.471: E/error(13435): read data errorrn03-02 10:15:57.471: E/error(13435): java.io.IOException: read data errorrn03-02 10:15:57.471: E/error(13435): at com.nenglong.jxpt.client.transport.Transport.receive(Transport.java:98)rn03-02 10:15:57.471: E/error(13435): at com.nenglong.jxpt.client.transport.Transport.submit(Transport.java:52)rn03-02 10:15:57.471: E/error(13435): at com.nenglong.jxpt.client.service.system.StateService.state(StateService.java:93)rn03-02 10:15:57.471: E/error(13435): at com.nenglong.jxpt.client.service.system.StateService.run(StateService.java:63)rn03-02 10:15:57.471: E/error(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.481: V/l(13435): errorrn03-02 10:15:57.481: V/l(13435): java.lang.Exception: 网络出现异常.rn03-02 10:15:57.481: V/l(13435): at com.nenglong.jxpt.client.transport.Transport.receive(Transport.java:118)rn03-02 10:15:57.481: V/l(13435): at com.nenglong.jxpt.client.transport.Transport.submit(Transport.java:52)rn03-02 10:15:57.481: V/l(13435): at com.nenglong.jxpt.client.service.system.StateService.state(StateService.java:93)rn03-02 10:15:57.481: V/l(13435): at com.nenglong.jxpt.client.service.system.StateService.run(StateService.java:63)rn03-02 10:15:57.481: V/l(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.506: W/System.err(13435): java.lang.Exception: 网络出现异常.rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.transport.Transport.receive(Transport.java:118)rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.transport.Transport.submit(Transport.java:52)rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.service.system.StateService.state(StateService.java:93)rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.service.system.StateService.run(StateService.java:63)rn03-02 10:15:57.511: W/System.err(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.511: V/l(13435): nullrn03-02 10:15:57.511: V/l(13435): java.lang.NullPointerExceptionrn03-02 10:15:57.511: V/l(13435): at com.nenglong.jxpt.client.service.system.StateService.state(StateService.java:95)rn03-02 10:15:57.511: V/l(13435): at com.nenglong.jxpt.client.service.system.StateService.run(StateService.java:63)rn03-02 10:15:57.511: V/l(13435): at java.lang.Thread.run(Thread.java:1096)rn03-02 10:15:57.511: W/System.err(13435): java.net.SocketException: Socket output is shutdownrn03-02 10:15:57.511: W/System.err(13435): at java.net.Socket.shutdownOutput(Socket.java:834)rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.transport.Connector.close(Connector.java:138)rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.transport.Connector.init(Connector.java:270)rn03-02 10:15:57.511: W/System.err(13435): at com.nenglong.jxpt.client.activity.system.LoginActivity$4.run(LoginActivity.java:309)rn03-02 10:15:57.511: W/System.err(13435): at java.lang.Thread.run(Thread.java:1096)rn 论坛

没有更多推荐了,返回首页