Hi,
I have downloaded the docsum_3.4.xsd
from ftp://ftp.ncbi.nlm.nih.gov/snp/specs/
After generating classes from xsd file, I have sent list of rsIds in batches and tried to get the rsInformation such as start and end positions, etc.
However while unmarshalling Rs class (after working for a number of rsIDs successfully)
I got java.lang.NumberFormatException
.
java.lang.NumberFormatException: Not a number: u
at com.sun.xml.internal.bind.DatatypeConverterImpl._parseInt(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$17.parse(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$17.parse(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StructureLoader.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.handleStartElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source)
What can be the reason? Any idea?
Related my code is below: After calling Rs rs=unmarshaller.unmarshal(reader, Rs.class).getValue();
I got java.lang.NumberFormatException
.
String uri="http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=snp&id="+commaSeparatedRsIdList+"&retmode=xml";
XMLEventReader reader= xmlInputFactory.createXMLEventReader(new StreamSource(uri));
while(reader.hasNext())
{
XMLEvent evt=reader.peek();
if(!evt.isStartElement())
{
reader.nextEvent();
continue;
}
StartElement start=evt.asStartElement();
String localName=start.getName().getLocalPart();
if(!localName.equals("Rs"))
{
reader.nextEvent();
continue;
}
Rs rs=unmarshaller.unmarshal(reader, Rs.class).getValue();
......
Thanks in advance,
Burçak
marshalling is about converting data between two programming environments, and has to convert all variables from one format to another. It's going to cause strange errors with no clear resolution because the two pieces don't line up. You'll have to find out what each end of the code is inputting and outputting.
When the data is invalid, then such a Java Exception is the correct and expected behavior. Your code has to handle the event that an unmarshal fails. Right now your code assumes everything is clean, which is nonsense for XML over the web. You should expect broken data.
Inspect the returned XML object, it apparently has a letter 'u' where you expected a number, hence the "number format exception".