Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Class cast exception when saving to XML(Generated code not saving to XML)
Class cast exception when saving to XML [message #1744692] Thu, 29 September 2016 13:59 Go to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 52
Registered: July 2016
Member
All,

I am getting an error when trying to save an EMF object graph. All my /EMF code was generated from a set of XSDs. These produce three ecore files. Two of these are dependencies of one. Since everything is generated without error, why would this class cast happen. It must be something in the XSDs.

I've used EMF extensively but this is a first. Does anyone know what might be causing this?

java.lang.ClassCastException: namespace.impl.NamespaceFactoryImpl cannot be cast to org.eclipse.emf.ecore.xml.namespace.XMLNamespaceFactory
	at org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceFactoryImpl.init(XMLNamespaceFactoryImpl.java:46)
	at org.eclipse.emf.ecore.xml.namespace.XMLNamespaceFactory.<clinit>(XMLNamespaceFactory.java:30)
	at org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl.<init>(XMLNamespacePackageImpl.java:90)
	at org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl.init(XMLNamespacePackageImpl.java:117)
	at org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage.<clinit>(XMLNamespacePackage.java:69)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.addNamespaceDeclarations(XMLSaveImpl.java:900)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:607)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:251)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:389)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
	at fhir.forecast.Save.it(Save.java:36)
	at fhir.forecast.SaveTest.testIt(SaveTest.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at ...
Re: Class cast exception when saving to XML [message #1744720 is a reply to message #1744692] Thu, 29 September 2016 15:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31917
Registered: July 2009
Senior Member
It seems you registered something that uses the same namespace as the built-in one, i., String eNS_URI = "http://www.w3.org/XML/1998/namespace". You should reuse the generated one in your model (when you load the GenModel you should use the existing package in the bottom half of the wizard.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Class cast exception when saving to XML [message #1744722 is a reply to message #1744720] Thu, 29 September 2016 16:18 Go to previous message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 52
Registered: July 2016
Member
Thanks Ed that worked.
Previous Topic:[EMF + ATL] Running ATL transformation on UML2 model: org.eclipse.emf.ecore.xmi.IllegalValueExceptio
Next Topic:[Databinding] Nested properties with master-observable
Goto Forum:
  


Current Time: Wed Jun 23 06:55:49 GMT 2021

Powered by FUDForum. Page generated in 0.02470 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top