×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Question xml parsing exception in e71

    Hi,

    I tested my midlet with nokia 5230 it works fine. But at e71 it throw exception java.util.NoSuchelementException. Why is it so? What is the solution? I'm concerned what will happen with other device.
    Do it now! Today will be yesterday tomorrow - MadSum

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: xml parsing exception in e71

    Hi madsum,

    Which API are you using (JSR-172 or another external library)? Can you provide a code sample, or have you identified the method call that throws the exception?

    In case you are using JSR-172, you cannot use the following system properties with E71:

    xml.jaxp.subset.version
    The version of JAXP Subset APIs supported by the device. The returned value is 1.0.

    xml.rpc.subset.version
    The version of JAXP-RPC Subset APIs supported by the device. The returned value is 1.0.

    The reason is that the above properties were added on S60 3rd Edition Feature Pack 2 Platform, while E71 is S60 3rd Edition Feature Pack 1.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: xml parsing exception in e71

    I'm using jsr-172 for xml parser. I don't know whether I'm using "xml.jaxp.subset.version" or "xml.rpc.subset.version". Can't say exact line where is exception. I can't debug Because I'm using bluetooth in app.

    Here is parser code call:-

    for(int j=0;j<ids.length;j++)
    {
    DataElement ServiceName;
    try{
    ServiceName=serviceRecords[0].getAttributeValue(ids[j]);
    //If this is a String Attribute
    if(ServiceName.getDataType()==DataElement.STRING)
    {
    midlet.form.append("\nSName: "+ServiceName.getValue());

    StreamConnection strcon;

    strcon = (StreamConnection) Connector.open(connectionURL);
    OutputStream outp = strcon.openOutputStream();
    String msg = "weather";
    outp.write(msg.getBytes());
    outp.flush();
    outp.close();

    InputStream inp = strcon.openInputStream();


    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();

    saxParser.parse(inp,event);




    inp.close ();
    strcon.close ();



    }
    }

    catch (Exception e)
    {
    midlet.form.append("exception: ###"+e.toString());
    }
    }

    here is the xml parser implementation:-

    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import java.util.*;

    class EventHandler extends DefaultHandler
    {
    private BTEngine btEngine;
    public Vector weathers = new Vector();
    private Stack stack = new Stack();

    public EventHandler (BTEngine midlet)
    {
    this.btEngine = midlet;
    }

    public void startDocument() throws SAXException {}

    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
    {
    if(qName.equals("data"))
    {
    Weather weather = new Weather();
    weathers.addElement(weather);
    }
    stack.push(qName);
    }

    public void characters(char[] ch, int start, int length) throws SAXException
    {
    String chars = new String(ch, start, length).trim();
    if(chars.length() > 0)
    {
    String qName = (String)stack.peek();
    Weather currentWeather = (Weather)weathers.lastElement();
    if (qName.equals("winddirection"))
    {
    currentWeather.setWinddirection(chars);
    }
    else if(qName.equals("windspeed"))
    {
    currentWeather.setWindspeed(chars);
    }
    else if(qName.equals("temperature"))
    {
    currentWeather.setTemperature(chars);
    }
    else if(qName.equals("humidity"))
    {
    currentWeather.setHumidity(chars);
    }
    else if(qName.equals("rain"))
    {
    currentWeather.setRain(chars);
    }
    }
    }

    public void endElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
    {
    stack.pop();
    }

    public void endDocument() throws SAXException
    {
    StringBuffer result = new StringBuffer();
    for (int i=0; i<weathers.size(); i++)
    {
    Weather currentWeather = (Weather)weathers.elementAt(i);
    result.append("Winddirection: "+currentWeather.getWinddirection() + "\n");
    result.append("Windspeed: "+currentWeather.getWindspeed() + "\n");
    result.append("Temperature: "+currentWeather.getTemperature() + "\n");
    result.append("Humidity: "+currentWeather.getHumidity() + "\n");
    result.append("Rain: "+currentWeather.getRain() + "\n");
    }
    btEngine.print(result);

    }
    }
    Do it now! Today will be yesterday tomorrow - MadSum

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: xml parsing exception in e71

    Hi madsum,

    It's hard to say. It's necessary to debug as the error might be related to input/output operations. You could use the Ecmt agent along with your Symbian SDK. You could add some System.out.println("") lines in your code, that can print directly into your IDE's console while having your device connected to your PC and while running your MIDlet. You can read more about how to install and use Ecmt agent here:

    http://library.developer.nokia.com/t...63%6d%74%22%20

    Also, in order to narrow down the code block that throws the exception, I would suggest replacing the "throws SAXException" declarations with try catch blocks within each method. For example consider replacing this:

    Code:
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
    { 
    if(qName.equals("data"))
    {
    Weather weather = new Weather();
    weathers.addElement(weather);
    }
    stack.push(qName);
    }
    with this:
    Code:
    public void startElement(String uri, String localName, String qName, Attributes attributes) { 
    try{
         if(qName.equals("data"))
         {  
              Weather weather = new Weather();
              weathers.addElement(weather);
         }
         stack.push(qName);
       }catch(Exception e){System.out.println("A different message for each method block");}
    }

  5. #5
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: xml parsing exception in e71

    FYI. There is (was?) a known issue for the XML parser on S60 3rd Edition FP1 devices which could be related / causing this
    http://www.developer.nokia.com/Commu...ops_characters

    Hartti

  6. #6
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: xml parsing exception in e71

    That's the reason I hate Symbian. It's really good Symbian crap dead.
    Do it now! Today will be yesterday tomorrow - MadSum

  7. #7
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: xml parsing exception in e71

    Was this the cause for your problems?

    Hartti

  8. #8
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: xml parsing exception in e71

    well it happens many times in various situation. All it made me hate more and more over times.
    Do it now! Today will be yesterday tomorrow - MadSum

Similar Threads

  1. Suspended: Signal 'Exception 0' received. Description: A data abort exception occured
    By amit04.kumar in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2010-10-12, 12:57
  2. Replies: 1
    Last Post: 2010-09-09, 11:34
  3. Replies: 6
    Last Post: 2010-06-16, 09:21
  4. Replies: 3
    Last Post: 2010-05-24, 16:13
  5. Replies: 4
    Last Post: 2009-12-11, 09:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×