Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,484
Community Members
 
Community Events
165
Community Groups

Why I got an exception when I try to jaxbUnmarshaller.unmarshal

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>
 

 

1 answer

1 vote

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

ok, that's not satisfying, but thanks anyway!

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you