Skip to main content



      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 09:59 Go to next message
Eclipse UserFriend
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 11:55 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Class cast exception when saving to XML [message #1744722 is a reply to message #1744720] Thu, 29 September 2016 12:18 Go to previous message
Eclipse UserFriend
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 Jul 02 20:23:02 EDT 2025

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

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

Back to the top