SOM-Research / emf-rest

EMF as RESTFul APIs
https://som-research.uoc.edu/tools/emf-rest/
Eclipse Public License 1.0
39 stars 15 forks source link

Nullpointer Exception while trying Example #12

Closed Kylex87 closed 7 years ago

Kylex87 commented 9 years ago

Hi,

I'm currently trying to get the example project running, but it's already throwing exceptions at the generation step. I followed http://emf-rest.com/install.html and created a new simple maven project through eclipse. Copied over the Example.ecore into the src/main/resources folder and also copied over the Simpsons.xmi into the same folder. I installed the newest version from your update site: EMF-REST 2.0.3.201503272048 com.rest.emf.feature.group EMF-REST After that I started the generation through the context menu on the Example.ecore. You can see in the console output that there is a NullpointerException.

Starting MTC: MTC
Setting variable [output] value to: /a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest/src/main/java
Setting variable [ecore_file] value to: /a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest/src/main/resources/Example.ecore
Setting variable [genModel_file] value to: /a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest/src/main/resources/Example.genmodel
Setting variable [output_js] value to: /a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest/src/main/webapp/scripts
Setting variable [pluginName] value to: emf-rest
Setting variable [foreignModel] value to: Example.ecore
Setting variable [modelName] value to: Simpsons
Setting variable [output_pom] value to: /a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest
Initializing Model Environments.
Finished Model Environments Initialization.
Model ready : Ecore Fully Annotated(/a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest/src/main/resources/Example.ecore)
Executing Ecore -> JavaScript API transformation
Executing Ecore->Genmodel transformation
Executing Default Index transformation
Exception executing Default Index transformation
Ecore -> JavaScript API transformation finished.
Executing pom transformation
pom transformation finished.
Model ready : GenModel(/a/thoros/thoros/steffenboersig/workspaceCammunda2/emf-rest/src/main/resources/Example.genmodel)
Ecore->Genmodel transformation finished.
Executing GenerateEMF transformation
java.lang.NullPointerException
    at com.emf.rest.standalone.PluginResourceLocator.getTarget(PluginResourceLocator.java:188)
    at com.mtcflow.engine.egl.EGLTransformationExecutor$1.createModule(EGLTransformationExecutor.java:51)
    at com.mtcflow.engine.epsilon.common.EpsilonExecutor.execute(EpsilonExecutor.java:93)
    at com.mtcflow.engine.egl.EGLTransformationExecutor.executeTransformation(EGLTransformationExecutor.java:88)
    at com.mtcflow.engine.core.MTCChoreographer$1.run(MTCChoreographer.java:628)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Textual File ready : EMF Code()
Executing Ecore -> Services transformation
GenerateEMF transformation finished.
Ecore -> Services transformation finished.

Apart from the obvious problem while generating, I noticed that while using my real emf model the corresponding genmodel that i copied next to the ecore file is being changed when the generation starts. Don't you use the existant genmodel if it is present already? Why is my original genmodel changed?

Regards, Steffen

hamzaed commented 9 years ago

Hi Steffen, Thanks for you interest in EMF-REST. Do you get the NullPointerException while using your model or the example model? You're right about the genmodel file. We create a custom genmodel file because we're not using the default JET templates to generate the domain classes. We extend the default JET templates to add all the required features for REST(i.e. JAXB annotations) and Validation (i.e., OCL interpreter). So we have to create a genmodel model and declare the location of our JET templates. Please take a look at the file https://github.com/emf-rest/emf-rest/blob/master/emf-rest-src/emf-rest/src/com/emf/rest/EMFGenerator.java. You can customize this class to add your genmodel properties.

Regards, Hamza

doggy-dev commented 7 years ago

I have the same problem. It seems this plugin expects that src/main/webapp existst. Unfortunately I think this is not documented.

hamzaed commented 7 years ago

The generator does create the src/main/webapp folder. I close this issue due to insufficient resources to identify the problem.