Getting Groovy and JAXB to play nice together has been previously discussed many times. A good solution to the problem is presented here: Stack Overflow.
However, I started running into some problems when I upgraded to Groovy 1.8. Take the following class definition:
import javax.xml.bind.annotation.*
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class JobResult {
@XmlElement String status
@XmlElement String exitDescription
}
During compliation, I received the following error:
symbol: variable XmlAccessType
@javax.xml.bind.annotation.XmlRootElement() @javax.xml.bind.annotation.XmlAccessorType(value=XmlAccessType.NONE) public class JobResult
/home/prystasj/workspace/project/target/generated-sources/groovy-stubs/main/org/oclc/controlledheading/admin/JobResult.java:[10,106] an enum annotation value must be an enum constant
Confused, I first tried using a static import:
import javax.xml.bind.annotation.*
import static javax.xml.bind.annotation.XmlAccessType.NONE
@XmlRootElement
@XmlAccessorType(NONE)
public class JobResult {
@XmlElement String status
@XmlElement String exitDescription
}
Giving me a different error:
[ERROR] /home/prystasj/project/target/generated-sources/groovy-stubs/main/prystasj/JobResult.java:[10,93] cannot find symbol
symbol: variable NONE
@javax.xml.bind.annotation.XmlRootElement() @javax.xml.bind.annotation.XmlAccessorType(value=NONE) public class JobResult
A solution I used was to fully qualify the path to field inside the XmlAccessorType annotation:
import javax.xml.bind.annotation.*
@XmlRootElement
@XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.NONE)
public class JobResult {
@XmlElement String status
@XmlElement String exitDescription
}
No comments:
Post a Comment