使用JavaAPIForKML写入KML文件的问题

时间:2012-12-18 13:31:07

标签: java jaxb eclipse-rcp kml jak

我试图从文本文件生成KML文件。 当我试图编组内存文件时,我遇到了异常。 任何线索?

javax.xml.bind.PropertyException: name: com.sun.xml.bind.namespacePrefixMapper value: de.micromata.opengis.kml.v_2_2_0.Kml$NameSpaceBeautyfier@1cfa4b2
    at javax.xml.bind.helpers.AbstractMarshallerImpl.setProperty(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.setProperty(Unknown Source)
    at de.micromata.opengis.kml.v_2_2_0.Kml.createMarshaller(Kml.java:642)
    at de.micromata.opengis.kml.v_2_2_0.Kml.marshal(Kml.java:682)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.Trampoline.invoke(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.MethodUtil.invoke(Unknown Source)

1 个答案:

答案 0 :(得分:0)

使用com.sun.xml.bind.namespacePrefixMapper时,您需要确保在课程路径上有JAXB RI(或EclipseLink JAXB (MOXy)

JDK包含JAXB RI的软件包重命名版本,因此您可以尝试使用以下属性名称:

com.sun.xml.internal.bind.namespacePrefixMapper

了解更多信息