Building on the previews answers from colleagues, just in case anybody is still looking for an answer.
I had the issue of having the root element of my scheme being defined as:
<schema>
<element name="foo" type="bar" />
<complexType name="bar" />
</schema>
And therefore I was getting a Cast Exception at:
try {
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(mobilityConfigType.getClass().getPackage().getName());
javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
File f = FileUtil.toFile(this.getPrimaryFile());
mobilityConfigType = (MobilityModelConfigType)unmarshaller.unmarshal(FileUtil.toFile(this.getPrimaryFile()));
} catch (javax.xml.bind.JAXBException ex) {
java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex); //NOI18N
}
What I did was to change the first line of the try block to:
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(mobilityConfigType.getClass().getName());
That resolved the problem for me.