Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ecore2GenModel with refGenModel(Null pointer exceptions when attempting to use Ecore2GenModel with refGenModel)
Ecore2GenModel with refGenModel [message #1772632] Wed, 13 September 2017 09:36 Go to next message
Richard Williamson is currently offline Richard WilliamsonFriend
Messages: 3
Registered: September 2017
Junior Member
I am attempting to generate a .genmodel file from an .ecore file. This works fine using the following command for an ecore file which does not reference any other ecore files having a path of the form ../../somefolder/model/some_other_file.ecore.

eclipse -noSplash -application org.eclipse.emf.importer.ecore.Ecore2GenModel some_file.ecore


If some other ecore files with paths as in my first paragraph are referenced, then I get a NullPointerException with the following stack trace.

org.eclipse.core.runtime.CoreException: Error
        at org.eclipse.emf.importer.ModelImporterApplication$1.run(ModelImporterApplication.java:122)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262)
        at org.eclipse.emf.importer.ModelImporterApplication.run(ModelImporterApplication.java:136)
        at org.eclipse.emf.importer.ModelImporterApplication.start(ModelImporterApplication.java:100)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
Caused by: java.lang.NullPointerException
        at org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl.initialize(GenModelImpl.java:9988)
        at org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl.initialize(GenModelImpl.java:9949)
        at org.eclipse.emf.importer.ModelImporter.adjustGenModel(ModelImporter.java:864)
        at org.eclipse.emf.importer.ecore.EcoreImporter.adjustGenModel(EcoreImporter.java:120)
        at org.eclipse.emf.importer.ModelImporter.prepareGenModelAndEPackages(ModelImporter.java:710)
        at org.eclipse.emf.importer.ModelImporterApplication.doExecute(ModelImporterApplication.java:606)
        at org.eclipse.emf.importer.ModelImporterApplication.execute(ModelImporterApplication.java:214)
        at org.eclipse.emf.importer.ModelImporterApplication.run(ModelImporterApplication.java:173)
        at org.eclipse.emf.importer.ModelImporterApplication.run(ModelImporterApplication.java:157)
        at org.eclipse.emf.importer.ModelImporterApplication$1.run(ModelImporterApplication.java:118)
        ... 17 more


I assume that one is supposed to use the -refGenModel option in this case. I have done so, in the following way, but the same NullPointerException occurs.

eclipse -noSplash -application org.eclipse.emf.importer.ecore.Ecore2GenModel some_file.ecore -refGenModel ../../somefolder/model/some_other_file.genmodel http://some_ns_uri -refGenModel platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel http://www.eclipse.org/emf/2002/GenModel


I also tried removing the second -refGenModel pair of arguments; still the NullPointerException occurs.

If I use an IDE to generate the genmodel file, the following is present in the genmodel file.

usedGenPackages="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore ../../somefolder/model/some_other_file.genmodel#//something"


I have studied the Eclipse source code from which the error is occurring, and I have tried every permutation that I can think of, without being able to get it to work. Hopefully somebody knows the correct syntax for this case!
Re: Ecore2GenModel with refGenModel [message #1774289 is a reply to message #1772632] Thu, 12 October 2017 13:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Sorry, I wasn't seeing posts because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=525901

Those darned things are so fragile, I think you're best to do this in the IDE and keep the *.genmodel around so that you don't need to do this at all.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore2GenModel with refGenModel [message #1774474 is a reply to message #1774289] Mon, 16 October 2017 07:07 Go to previous messageGo to next message
Richard Williamson is currently offline Richard WilliamsonFriend
Messages: 3
Registered: September 2017
Junior Member
Thanks for the reply!

Unfortunately, I prefer not to use an IDE! :-)

Presumably whatever the IDE is doing is not fragile. Would it not be possible to expose that in an external script?
Re: Ecore2GenModel with refGenModel [message #1774482 is a reply to message #1774474] Mon, 16 October 2017 08:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

A direct Ecore to GenModel conversion is unlikely to be appropriate since you probably need to add details such as packagePrefixes, copyrights, runtimeLevels... EMD 12.4M3 adds support for further annotations so it may be possible to have these in your Ecore model in the future. (For a single target platform that can be useful, for multiple targets it is a mistake, you may have multiple GenModels one per platform all sharing one Ecore model).

More likely you want to update your GenModel to accommodate changes in your Ecore model. This is called reconcile() in the code.

For Ant enthusiasts EMF provides Ant tasks for Import/Export.

I prefer to use MWE2 for which the GIT\org.eclipse.ocl\examples\org.eclipse.ocl.examples.build\src\org\eclipse\ocl\examples\build\utilities\GenerateModel.java bean updates a GenModel then generates Java. You could simplify it to just update the GenModel.

Regards

Ed Willink
Re: Ecore2GenModel with refGenModel [message #1774496 is a reply to message #1774482] Mon, 16 October 2017 13:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Unfortunately I prefer not to maintain Ant tasks that almost no one uses... Whatever works, great, whatever doesn't, is open source...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore2GenModel with refGenModel [message #1774506 is a reply to message #1774496] Mon, 16 October 2017 15:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

After finding the magic prerequisite extraRequirements target platform when migrating QVTo to Tycho, I was pleasantly surprised to find that the UML2 Ant tasks built, packaged and tested without any intervention from me.

But agreed, we probably spend more time maintaining the Ant tasks than anyone spends using them. It would be good to get the deprecation announcement in place, e.g. at

https://wiki.eclipse.org/EMF/FAQ#How_can_I_use_the_EMF_Ant_tasks.3F
a generic EMF deprecation wiki page
this newsgroup
emf-dev

then perhaps at EMF 2.15 they could more legitimately vanish.

Regards

Ed Willink
Re: Ecore2GenModel with refGenModel [message #1777647 is a reply to message #1774506] Fri, 01 December 2017 09:12 Go to previous messageGo to next message
Richard Williamson is currently offline Richard WilliamsonFriend
Messages: 3
Registered: September 2017
Junior Member
Hi,

Thanks for the responses, and apologies for the slow reply. It's actually generating the Java code from the command line that I'm interested in. I was shown the second edition of the EMF book, and the only thing I could find in this was to combine a pair of scripts, one of which generates the genmodel, and one of which from this generates the Java code. If these scripts are now deprecated, it would nice to have some easily accessible reference online to that.

Regarding "almost no-one uses", surely there must be a non-trivial group of people who need to use EMF but prefer not to use the Eclipse IDE for day to day development.
Re: Ecore2GenModel with refGenModel [message #1777656 is a reply to message #1777647] Fri, 01 December 2017 09:41 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you want to use a command line then I recommend you investigate MWE2 for which you can find may relevant helper tasks in GIT\org.eclipse.ocl\examples\org.eclipse.ocl.examples.build\src\org\eclipse\ocl\examples\build\utilities

I find that I have only minor problems with MWE2 since it runs as a simple Java task that I can debug in conventional fashion.

In contrast ANT has endless taskpath challenges and is resistant to debugging. Of course since I avoid ANT, I always forget how I figured it out last time, and so each revisit usually meets my expectation of agony.

Regards

Ed Willink
Previous Topic:[CDO] OK to attach transient object to CDOTransaction?
Next Topic:Resource.load error: ">" is not legal
Goto Forum:
  


Current Time: Tue Apr 23 17:53:43 GMT 2024

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

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

Back to the top