0

Getting this error : java.lang.RuntimeException: org.simpleframework.xml.core.MethodException: Annotation @org.simpleframework.xml.Element(data=false, name=, required=false, type=void) must mark a set or get method

IMSoP
  • 89,526
  • 13
  • 117
  • 169
ashishsingh
  • 71
  • 1
  • 2
  • My xml is The data included in this document is from www.openstreetmap.org. The data is made available under ODbL. – ashishsingh May 28 '20 at 10:50
  • Please [edit] details like that into the question itself; comments don't support the same formatting, and are intended to be temporary. You might also want to edit the title to be a bit clearer what you're actual problem is. – IMSoP May 29 '20 at 08:20

1 Answers1

1

This is the same problem as: kotlin data class + bean validation jsr 303

You need to use Annotation use-site targets since the default for an annotation on a property is prioritized as:

parameter (if declared in constructor) property (if the target site allows, but only Kotlin created annotations can do this) field (likely what happened here, which isn't what you wanted). Use get or set target to place the annotation on the getter or setter. Here it is for the getter:

@Root(name = "response")
public class User() {
    @get:Element public var result: String? = null
    @get:Element public var token: String? = null
    @get:Element public var uid: String? = null
}

See the linked answer for the details.

See the question response: Here

MexiCano
  • 271
  • 1
  • 11