07-15 01:36:59.221: W/dalvikvm(2073): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
07-15 01:36:59.281: E/AndroidRuntime(2073): FATAL EXCEPTION: AsyncTask #1
07-15 01:36:59.281: E/AndroidRuntime(2073): java.lang.RuntimeException: An error occured while executing doInBackground()
07-15 01:36:59.281: E/AndroidRuntime(2073):  at android.os.AsyncTask$3.done(AsyncTask.java:299)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.util.concurrent.FutureTask.run(FutureTask.java:239)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.lang.Thread.run(Thread.java:856)
07-15 01:36:59.281: E/AndroidRuntime(2073): Caused by: java.lang.NullPointerException
07-15 01:36:59.281: E/AndroidRuntime(2073):  at com.chris.lr.slidemenu.MainActivity$ProductHandler.endElement(MainActivity.java:281)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at com.chris.lr.slidemenu.MainActivity$GetHttpTask.doInBackground(MainActivity.java:193)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at com.chris.lr.slidemenu.MainActivity$GetHttpTask.doInBackground(MainActivity.java:1)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-15 01:36:59.281: E/AndroidRuntime(2073):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-15 01:36:59.281: E/AndroidRuntime(2073):  ... 3 more相关代码如下,
    void httpGet() {
     GetHttpTask task = new GetHttpTask();
     task.execute("http://www.cnzjmsa.gov.cn/rssweb/rsstzgg/index.xml");
    }
    
    public class GetHttpTask extends AsyncTask<String, Integer, String> {
   
     public GetHttpTask() {
        }
    
     protected void onPreExecute() {
    
     }
    
     protected String doInBackground(String... params) {
         HttpGet httpRequest = new HttpGet(params[0]);
         HttpClient httpclient = new DefaultHttpClient();
        
         //mShowHtml.setText("");
         try {
         HttpResponse httpResponse = httpclient.execute(httpRequest);
        
         if(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
         HttpEntity entitiy = httpResponse.getEntity();
        
         InputStream in = entitiy.getContent();
        
         InputSource source = new InputSource(in);
        
         SAXParserFactory sax = SAXParserFactory.newInstance();
         XMLReader xmlReader = sax.newSAXParser().getXMLReader();
        
         xmlReader.setContentHandler(new ProductHandler());
        
         xmlReader.parse(source);
        
         }
         else {
         ;
         }
        
         }catch(IOException e){
         e.printStackTrace();
         }catch(SAXException e) {
         e.printStackTrace();
         }catch(ParserConfigurationException e) {
         e.printStackTrace();
         }
         return null;
     }
    
     protected void onPostExecute(String result) {
     }
    }我昨天还可以运行并且正常解析XML的数据返回到当前LISTVIEW上,为什么今天突然报错呢,程序运行后大约5秒直接退出了asynctask异常

解决方案 »

  1.   

    xml解析出错,打log看看从服务器收到内容的是什么?
      

  2.   

    Caused by: java.lang.NullPointerException
    07-15 01:36:59.281: E/AndroidRuntime(2073):  at com.chris.lr.slidemenu.MainActivity$ProductHandler.endElement(MainActivity.java:281)找到代码看看