带有简单 XML serializer.write 的神秘空指针异常
我在使用 Simple Xml Serializer 从 Android 项目中的复杂对象构建消息时遇到问题。奇怪的是,昨天它运行良好;序列化对象已写入 StringWriter,一切顺利。出于某种原因,我现在得到了这个:
03-08 12:01:12.884: WARN/System.err(444): java.lang.NullPointerException
at org.simpleframework.xml.core.Traverser.write(Traverser.java:225)
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:1187)
at org.simpleframework.xml.core.Persister.write(Persister.java:1169)
at org.simpleframework.xml.core.Persister.write(Persister.java:1147)
它在serializer.write()线上不断爆炸,我不明白为什么。
//xmlMsg is the object to be serialized.
Serializer serializer = new Persister();
StringWriter outMsg = null;
serializer.write(xmlMsg, outMsg);
I'm having trouble using Simple Xml Serializer to build a Message from a complex object in my android project. The strange part is that it worked fine yesterday; the serialized object was written to a StringWriter and all was well. For some reason I now get this:
03-08 12:01:12.884: WARN/System.err(444): java.lang.NullPointerException
at org.simpleframework.xml.core.Traverser.write(Traverser.java:225)
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:1187)
at org.simpleframework.xml.core.Persister.write(Persister.java:1169)
at org.simpleframework.xml.core.Persister.write(Persister.java:1147)
It keeps blowing up on the serializer.write() line and I can't figure out why.
//xmlMsg is the object to be serialized.
Serializer serializer = new Persister();
StringWriter outMsg = null;
serializer.write(xmlMsg, outMsg);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 javadoc 看来,该方法将尝试写入
Writer
参数似乎是合理的,因此它不应该是null
。From the javadoc it seems reasonable to me that the method will attempt to write to the
Writer
parameter, thus it shouldn't benull
.