Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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
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)

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(
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$2.delegatedGetFactory(
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.getFactory(
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.getFactory(
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(
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

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