当使用 Moxy 作为 JAXB 实现时,以下类会导致异常:
@XmlRootElement(name="fraPage")
@XmlAccessorType(XmlAccessType.FIELD)
case class FraPage(@ScalaXmlTypeAdapter(value=classOf[FraSeqAdapter]) @ScalaXmlElementWrapper(name="fras") data:Seq[Fra],@XmlTransient id: FraPageId, @ScalaXmlElement header:FraPageHeader) extends PageWithId[FraPageId]{
private def this()= this(null,null,null)
lazy val isEmpty = data.isEmpty
}
Exception in thread "main" javax.xml.bind.JAXBException: 0
- with linked exception:
[java.lang.ArrayIndexOutOfBoundsException: 0]
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:908)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:157)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:170)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:157)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:117)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at com.gottex.gottware.services.Dummy$.main(Dummy.scala:16)
at com.gottex.gottware.services.Dummy.main(Dummy.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.eclipse.persistence.jaxb.compiler.MappingsGenerator.generateDirectCollectionMapping(MappingsGenerator.java:2004)
at org.eclipse.persistence.jaxb.compiler.MappingsGenerator.generateMapping(MappingsGenerator.java:501)
at org.eclipse.persistence.jaxb.compiler.MappingsGenerator.generateMappings(MappingsGenerator.java:2265)
at org.eclipse.persistence.jaxb.compiler.MappingsGenerator.generateMappings(MappingsGenerator.java:2225)
at org.eclipse.persistence.jaxb.compiler.MappingsGenerator.generateProject(MappingsGenerator.java:201)
at org.eclipse.persistence.jaxb.compiler.Generator.generateProject(Generator.java:185)
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:913)
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:905)
... 20 more
Process finished with exit code 1
发生了什么,为什么?我正在使用 JDK 1.6.0.25 和 Moxy 版本 2.4.0