I have a groovy script using in script runner. I try to map an XML file to my model classes. But I git this exception. Anybody an Idea why?
javax.xml.bind.JAXBException - with linked exception: [com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions groovy.lang.MetaClass ist eine Schnittstelle, und JAXB kann keine Schnittstellen verarbeiten. this problem is related to the following location: at groovy.lang.MetaClass at public groovy.lang.MetaClass Persons.getMetaClass() at Persons ]"
JIRA 8.20.5
The exception comes direct by the first line when I create the JAXBContext:
JAXBContext jaxbContext = JAXBContext.newInstance(Persons.class)
Her the model files
import javax.xml.bind.annotation.XmlAccessType
import javax.xml.bind.annotation.XmlAccessorType
import javax.xml.bind.annotation.XmlElement
import javax.xml.bind.annotation.XmlRootElement
@XmlRootElement(name = "persons")
@XmlAccessorType(XmlAccessType.FIELD)
class Persons {
@XmlElement(name = "persons")
private ArrayList<Person> persons = new ArrayList<Person>()
List<Person> getPersons() {
return persons
}
void setPersons(List<Person> persons) {
this.persons = persons
}
}
package com.schwermetall.buildingSecurity.dexicon.models
import javax.xml.bind.annotation.XmlAccessType
import javax.xml.bind.annotation.XmlAccessorType
import javax.xml.bind.annotation.XmlElement
@XmlAccessorType(XmlAccessType.FIELD)
class Person {
@XmlElement(name = "id")
String id
@XmlElement(name = "name")
String name
}
Her the XML
<?xml version="1.0" encoding="UTF-8"?>
<persons>
<person>
<id>100</id>
<name>Max Mustermann</name>
</person>
<person>
<id>200</id>
<name>Peter Peterson</name>
</person>
</persons>
I don't have experience with this.
But I found this https://stackoverflow.com/questions/1161147/how-do-i-get-groovy-and-jaxb-to-play-nice-together
I tried some sample code and couldn't get it to work either. Could be the way groovy is implemented in scriptrunner doesn't quite allow using JAXB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.