Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CLASS CAST EXCEPTION
CLASS CAST EXCEPTION [message #1739718] Thu, 04 August 2016 09:05 Go to next message
vinayaka krishnamurthy is currently offline vinayaka krishnamurthyFriend
Messages: 3
Registered: August 2016
Junior Member
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 14:48 Go to previous message
Aurélien Mora is currently offline Aurélien MoraFriend
Messages: 38
Registered: July 2014
Member
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: Tue Jun 15 11:10:34 GMT 2021

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

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

Back to the top