Reputation: 21
I am getting the error as mentioned. Adding code snippet to get more about what am I doing. Please have a look and help. Thanks in advance. My xml:
<?xml version="1.0" encoding="UTF-8"?>
<ClientConfigData>
<requestType>type1</requestType>
<refreshEnable>false</refreshEnable>
<compressionEnable>false</compressionEnable>
<transformationEnable>true</transformationEnable>
...
</ClientConfigData>
My Java:
@XmlRootElement
public class ClientConfigData {
private String requestType;
private boolean refreshEnable;
private boolean compressionEnable;
private boolean transformationEnable;
...
}
And here, I am creating java object from xml:
File configFile = new File(classLoader.getResource("ClientRegistration.xml").getFile());
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(ClientConfigData.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
ClientConfigData configData= (ClientConfigData) jaxbUnmarshaller.unmarshal(configFile);
System.out.println(configData);
} catch (JAXBException e) {
e.printStackTrace();
}
Upvotes: -1
Views: 2026
Reputation: 34900
You should add a qualified root element name to the @XmlRootElement
annotation. In your case it will be:
@XmlRootElement(name = "ClientConfigData")
By default JAXB
searches for clientConfigData
(with the lower-case first letter).
Upvotes: 3