Skip to main content



      Home
Home » Modeling » EMF » CLASS CAST EXCEPTION
CLASS CAST EXCEPTION [message #1739718] Thu, 04 August 2016 05:05 Go to next message
Eclipse UserFriend
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("ecore",EcoreResourceFactoryImpl)
val classLoader = kl.classLoader
System.out.println(System.getProperty("user.dir"));
val resource = (classLoader).getResource("/model/extlibrary.ecore")
var ff = URI.createFileURI(System.getProperty("user.dir")+"/model/extlibrary.ecore");

var URI ecoreFileURI = ff
var URI ecoreModelURI = ecoreFileURI.appendFragment("/"); //$NON-NLS-1$

var ResourceSet resourceSet = new ResourceSetImpl();
var res = resourceSet.getResource(ecoreModelURI,true)
var f = resourceSet.getEObject(ecoreModelURI, true)
println(f)


this gives me class cast Exception

Exception in thread "main" java.lang.ClassCastException: java.lang.Class cannot be cast to org.eclipse.emf.ecore.resource.Resource$Factory
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.convert(ResourceFactoryRegistryImpl.java:93)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$2.delegatedGetFactory(ResourceSetImpl.java:458)
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.getFactory(ResourceFactoryRegistryImpl.java:144)
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.getFactory(ResourceFactoryRegistryImpl.java:85)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:431)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:243)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:400)
Re: CLASS CAST EXCEPTION [message #1739804 is a reply to message #1739718] Thu, 04 August 2016 10:48 Go to previous message
Eclipse UserFriend
Hello,

I think you are registering a Class in the Resource.Factory.Registry, you should try to register an instance of ResourceFactory, like this :

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("ecore", new EcoreResourceFactoryImpl())


Previous Topic:[XCORE] ecore file generated in impl package
Next Topic:[CDO] Define fine grained object access with CDO security model ?
Goto Forum:
  


Current Time: Fri Sep 26 17:04:10 EDT 2025

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

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

Back to the top