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.
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
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.
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
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:
with 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); }
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");} }
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
That's the reason I hate Symbian. It's really good Symbian crap dead.
Do it now! Today will be yesterday tomorrow - MadSum
Was this the cause for your problems?
Hartti
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