Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:09:44+00:00 2026-06-18T03:09:44+00:00

I want to load an EMF model resource which was persistend before from an

  • 0

I want to load an EMF model resource which was persistend before from an Eclipse Plug-in Environment. I tried as follows.

// obtain a new resource set

ResourceSet resSet = new ResourceSetImpl();

// get the resource 

resSet.getResource(URI.createURI(location), true);

location is a path relative to the platform, e.g. platform:/resource/Project/default.mymodel

When I try to get the resource using URI.createURI(...) I get a ClassCastException: “MymodelFactoryImpl cannot be cast to org.eclipse.emf.ecore.resource.Resource$Factory”.

I cannot explain this. Can somebody please help me?

I already tried URI.createFileURI(location). This results in an IllegalArgumentException: “invalid relative pathName”.

Regards

The stack trace looks as follows.
java.lang.ClassCastException: de.uka.ipd.sdq.pcm.usagemodel.impl.UsagemodelFactoryImpl cannot be cast to org.eclipse.emf.ecore.resource.Resource$Factory
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.convert(ResourceFactoryRegistryImpl.java:94)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$2.delegatedGetFactory(ResourceSetImpl.java:458)
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.getFactory(ResourceFactoryRegistryImpl.java:145)
at org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl.getFactory(ResourceFactoryRegistryImpl.java:86)
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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:09:45+00:00Added an answer on June 18, 2026 at 3:09 am

    This is not supposed to be necessary, because the plug-in environment does it for you, but try to register the resource factory:

    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(fileExtension, new ModelResourceFactoryImpl());
    

    where fileExtension is the file extension of the resource to be loaded and the ModelResourceFactoryImpl should be a generated class extending ResourceFactoryImpl.

    However, after removing the following code, the model can be loaded.

    // Register the XMI resource factory for my extension
    Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("myextension", new XMIResourceFactoryImpl());
    

    It seems this was not the proper registration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want load ICON from exe's resource and draw it.
I want to load static web page from resource and to display it as
I want to load AlphaSkin's Imagelist from resource. Commonly I know, how to load
at first sorry my bad English I want load model in my plugin controller
I want to load data from MySql database to a HTTP form When I
I want to load PNG-file from resources. There is a roughly MFC-way (with CResourceStream
I want to load a palette from a bitmap file I have created. The
I want to load defined folders into my website from same system, now I
I want to load the data from a JSON file into a table. (With
I want to load an HTML div from an html file hosted on windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.