Skip to main content



      Home
Home » Modeling » EMF » Problem instantiating model(What does NS URI do ?)
Problem instantiating model [message #636396] Sun, 31 October 2010 21:00 Go to next message
Eclipse UserFriend
I generated some classes using EMF and now I want to instantiate them. I've created the xmi files associated with the model and metamodel. Now I want to load the model as an instance in my program, but it keeps throwing a NullPointerException.

My code is:

Map<String,Object> registry = EPackage.Registry.INSTANCE;
String workflowURI = ExcelEditorPackage.eNS_URI;
System.out.println(workflowURI);
ExcelEditorPackage wfPackage = (ExcelEditorPackage) registry.get(workflowURI); //throw NPE here
ExcelEditorFactory wfFactory = wfPackage.getExcelEditorFactory();
Page workflow = wfFactory.createPage();

It throws an at wfFactory because wfPackage is null. My NS URI is "http://www.sg/model" (this URL does not exist). I think something is wrong with the NS URI. SHould I point to some xmi file for the metamodel? All the examples I have seen just point to a random URL.

[Updated on: Sun, 31 October 2010 21:00] by Moderator

Re: Problem instantiating model [message #636408 is a reply to message #636396] Mon, 01 November 2010 02:00 Go to previous message
Eclipse UserFriend
Hi Al,

If you want to create instance of your model classes.
You can do by the following

ExcelEditorFactory.eInstance.createPage()... this creates an instance of Page.EMF generates a factory class for your models with which you can create your model class instances.


cheers,
Saurav
Previous Topic:itemProviderAdapterFactories
Next Topic:Creating SelectEntry for Attributes of a Class
Goto Forum:
  


Current Time: Sun Jul 06 08:01:29 EDT 2025

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

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

Back to the top