I need to upgrade Apache's xmlbeans.jar in my project from version 3.1.0 to 5.0.3 because it's a dependency of another jar. But doing so messes up some legacy webservice-related code which utilize XmlBeans as an XML processor, causing compiler errors.
The errors all look like this:
SomeDocument doc = SomeDocument.Factory.newInstance();
... where SomeDocument extends XmlObject.
With the jar's prvious version, the newInstance() method returned an instance of SomeDocument, no problem. However, the new version is trying to create an instance of the parent XmlObject.
How should I refactor this code? Can I cast the XmlObject instance to SomeDocument? Or should I use the XmlObjectFactory instead, as suggested by its javadoc. And if I should, how can I refactor the above code using that class instead?