Re: [Simple-support] NullPointerException for similar Element Names with different @Paths
Brought to you by:
niallg
|
From: amit.shipra <ami...@rb...> - 2012-08-10 13:18:07
|
In the XML Message 'sourceSystem' is at multiple places. I overlooked in my
haste. When I tried name="sourceSystem[1]" the actual tags were changed to
<ns0:sourceSystem[1]>value</sourceSystem[1]>.
Issue remains. Please help.
Amit-G.
Robert Massaioli-2 wrote:
>
> You just said previously that you had solved the problem? Is that not the
> case?
>
> On Fri, Aug 10, 2012 at 11:04 PM, amit.shipra
> <ami...@rb...>wrote:
>
>>
>> Could someone please help with this issue. Let me know if I am doing
>> anything
>> wrong here?? :-/
>>
>>
>> amit.shipra wrote:
>> >
>> > Hi there,
>> >
>> > XML looks like:
>> >
>> > <ns0:book id="BOOK">
>> > <ns0:identifier>
>> > <ns0:sourceSystem>DTCC</ns0:sourceSystem>
>> > </ns0:identifier>
>> > </ns0:book>
>> > <ns0:trader id="ID_EXECUTING_TRADER">
>> > <ns0:identifier>
>> > <ns0:sourceSystem>NYSE</ns0:sourceSystem>
>> > </ns0:identifier>
>> > </ns0:trader>
>> >
>> >
>> > and my JAVA code (for sourceSystem Element) is:
>> >
>> > @Element(name="sourceSystem")
>> > @Path("ns0:book/ns0:identifier")
>> > private String bookSourceSystem="system1";
>> >
>> >
>> > @Element(name="sourceSystem")
>> > @Path("ns0:trader/ns0:identifier")
>> > private String traderSourceSystem="system2";
>> >
>> >
>> > However, I am getting the NullPointerException:
>> >
>> > StackTrace:
>> > Exception in thread "main" java.lang.NullPointerException
>> > at
>> >
>> org.simpleframework.xml.core.InstantiatorBuilder.register(InstantiatorBuilder.java:461)
>> > at
>> >
>> org.simpleframework.xml.core.InstantiatorBuilder.register(InstantiatorBuilder.java:433)
>> > at
>> >
>> org.simpleframework.xml.core.StructureBuilder.process(StructureBuilder.java:283)
>> > at
>> >
>> org.simpleframework.xml.core.StructureBuilder.process(StructureBuilder.java:259)
>> > at
>> >
>> org.simpleframework.xml.core.StructureBuilder.process(StructureBuilder.java:200)
>> > at org.simpleframework.xml.core.Scanner.field(Scanner.java:511)
>> > at org.simpleframework.xml.core.Scanner.scan(Scanner.java:395)
>> > at org.simpleframework.xml.core.Scanner.<init>(Scanner.java:104)
>> > at
>> >
>> org.simpleframework.xml.core.ScannerFactory.getInstance(ScannerFactory.java:77)
>> > at
>> org.simpleframework.xml.core.Support.getScanner(Support.java:203)
>> > at
>> org.simpleframework.xml.core.Source.getScanner(Source.java:271)
>> > at org.simpleframework.xml.core.Source.getCaller(Source.java:300)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeReplace(Composite.java:1147)
>> > at
>> org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1124)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
>> > at
>> org.simpleframework.xml.core.Composite.write(Composite.java:975)
>> > at
>> org.simpleframework.xml.core.Composite.write(Composite.java:952)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeElement(Composite.java:1256)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeElement(Composite.java:1239)
>> > at
>> org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1127)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeElements(Composite.java:1087)
>> > at
>> >
>> org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
>> > at
>> org.simpleframework.xml.core.Composite.write(Composite.java:975)
>> > at
>> org.simpleframework.xml.core.Composite.write(Composite.java:952)
>> > at
>> org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
>> > at
>> org.simpleframework.xml.core.Traverser.write(Traverser.java:208)
>> > at
>> org.simpleframework.xml.core.Traverser.write(Traverser.java:186)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1180)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1162)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1140)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1259)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1241)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1222)
>> > at
>> org.simpleframework.xml.core.Persister.write(Persister.java:1201)
>> >
>> >
>> > Source code block:
>> >
>> > private void register(Label label, LabelMap map) throws Exception {
>> > String name = label.getName();
>> > String path = label.getPath();
>> >
>> > if(map.containsKey(name)) {
>> > Label current = map.get(name); <-- THIS RETURNS current AS
>> NULL.
>> > String key = current.getPath();
>> >
>> >
>> > Could we have only one Element even if @Paths are different? Struck
>> around
>> > this for long. Is there a work around?
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/NullPointerException-for-similar-Element-Names-with-different-%40Paths-tp34277238p34281760.html
>> Sent from the Simple XML Serialization mailing list archive at
>> Nabble.com.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li...
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
--
View this message in context: http://old.nabble.com/NullPointerException-for-similar-Element-Names-with-different-%40Paths-tp34277238p34281810.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|