Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem instantiating model(What does NS URI do ?)
Problem instantiating model [message #636396] Mon, 01 November 2010 01:00 Go to next message
Alex Loh is currently offline Alex LohFriend
Messages: 5
Registered: June 2010
Location: Austin, TX
Junior Member
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;
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 "" (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: Mon, 01 November 2010 01:00]

Report message to a moderator

Re: Problem instantiating model [message #636408 is a reply to message #636396] Mon, 01 November 2010 06:00 Go to previous message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
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.


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

Current Time: Tue Aug 04 15:05:27 GMT 2020

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

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

Back to the top