Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » emf.Ecore2Java Ant task is flaky
icon9.gif  emf.Ecore2Java Ant task is flaky [message #646586] Wed, 29 December 2010 01:04 Go to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 82
Registered: July 2009
Location: New York City, NY
Member
Hi all,

we're using the emf.Ecore2Java task in an external tools builder to generate the Java sources from a .genmodel file. Unfortunately, the task is producing somewhat inconsistent results and works only half of the time, it seems.
There is an Ant target that deletes the src-gen folder when the .ecore or .genmodel file is updated and another target that regenerates the src-gen folder if it is not present:

<target name="generate" depends="check-rebuild" unless="already-exists">
<mkdir dir="src-gen"/>
<eclipse.refreshLocal resource="com.intuit.eclipse.emf.tps.formset" depth="infinite"/>
<emf.Ecore2Java genmodel="model/formset.genmodel" reconcileGenModel="keep"
generateJavaCode="true"
generatetestsproject="false"
generateeditproject="false"
generateeditorproject="false"
generatemodelproject="true"
modelproject="com.intuit.eclipse.emf.tps.formset"
modelpluginid="com.intuit.eclipse.emf.tps.formset"
modelprojectfragmentpath="src-gen">
<model file="model/formset.ecore"/>
</emf.Ecore2Java>
</target>

First of all, without the eclipse.refreshLocal, the emf.Ecore2Java would report that it was generating all the source files, but the src-gen folder would still be empty after the task finished. Only when running the task a second time (?!) the src-gen folder was properly populated. Luckily (though somewhat inexplicably), adding the eclipse.refreshLocal task fixed that.
Now I have the problem that only a part of the sources is generated sometimes. Especially, the .util package with the base implementations of resources and resource factories often remains incomplete (i.e., a couple sources are generated while others are missing) after the project was just imported into the workspace. There are no indications on the console that would indicate that emf.Ecore2Java ran into any kind of trouble during execution, and the Ant build finishes successfully, so I'm not sure how to debug this.

Any ideas what's going here or how I could further debug this? I'm already running Ant with -d but nothing out of the ordinary is reported.

Thanks,

Mirko
Re: emf.Ecore2Java Ant task is flaky [message #646588 is a reply to message #646586] Wed, 29 December 2010 01:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Mirko,

Comments below.

Mirko Raner wrote:
> Hi all,
>
> we're using the emf.Ecore2Java task in an external tools builder to
> generate the Java sources from a .genmodel file. Unfortunately, the
> task is producing somewhat inconsistent results and works only half of
> the time, it seems.
Which half? :-P
> There is an Ant target that deletes the src-gen folder when the .ecore
> or .genmodel file is updated and another target that regenerates the
> src-gen folder if it is not present:
>
> <target name="generate" depends="check-rebuild" unless="already-exists">
> <mkdir dir="src-gen"/>
> <eclipse.refreshLocal resource="com.intuit.eclipse.emf.tps.formset"
> depth="infinite"/>
> <emf.Ecore2Java genmodel="model/formset.genmodel"
> reconcileGenModel="keep"
> generateJavaCode="true"
> generatetestsproject="false"
> generateeditproject="false"
> generateeditorproject="false"
> generatemodelproject="true"
> modelproject="com.intuit.eclipse.emf.tps.formset"
> modelpluginid="com.intuit.eclipse.emf.tps.formset"
> modelprojectfragmentpath="src-gen">
> <model file="model/formset.ecore"/>
> </emf.Ecore2Java>
> </target>
>
> First of all, without the eclipse.refreshLocal, the emf.Ecore2Java
> would report that it was generating all the source files, but the
> src-gen folder would still be empty after the task finished.
If the workspace is updated "externally" a refresh is needed to get the
state back in sync... Are there any problems reported in the error log?
> Only when running the task a second time (?!) the src-gen folder was
> properly populated.
I suppose something in the first attempt is doing a refresh.
> Luckily (though somewhat inexplicably), adding the
> eclipse.refreshLocal task fixed that.
> Now I have the problem that only a part of the sources is generated
> sometimes. Especially, the .util package with the base implementations
> of resources and resource factories often remains incomplete (i.e., a
> couple sources are generated while others are missing) after the
> project was just imported into the workspace.
I imagine if there are failures, they'd be recorded in the error log.
> There are no indications on the console that would indicate that
> emf.Ecore2Java ran into any kind of trouble during execution, and the
> Ant build finishes successfully, so I'm not sure how to debug this.
Given that the generator is more generally running within the IDE,
writing to System.out/err wouldn't normally be a good way to inform the
user...
>
> Any ideas what's going here or how I could further debug this? I'm
> already running Ant with -d but nothing out of the ordinary is reported.
The error log; <workspace>/.metadata/.log, is likely to yield
informative traces.
>
> Thanks,
>
> Mirko
>
Re: emf.Ecore2Java Ant task is flaky [message #646592 is a reply to message #646588] Wed, 29 December 2010 02:45 Go to previous messageGo to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 82
Registered: July 2009
Location: New York City, NY
Member
Good point, Ed! I forgot that emf.Ecore2Java actually runs inside the IDE and did not check the workspace log.
There are a couple of warnings like this in the log:

org.eclipse.emf.common.util.WrappedException: org.eclipse.emf.codegen.jet.JETException: ClassNotFoundException: org.eclipse.emf.codegen.ecore.templates.model.FactoryClass_
at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAda pter.generateJava(AbstractGeneratorAdapter.java:1112)
at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageG eneratorAdapter.generateFactoryInterface(GenPackageGenerator Adapter.java:520)
at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageG eneratorAdapter.generateModel(GenPackageGeneratorAdapter.jav a:220)
at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGene ratorAdapter.doGenerate(GenBaseGeneratorAdapter.java:221)
at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAda pter.generate(AbstractGeneratorAdapter.java:290)
at org.eclipse.emf.codegen.ecore.generator.Generator.generate(G enerator.java:617)
at org.eclipse.emf.codegen.ecore.generator.Generator.generate(G enerator.java:528)
at org.eclipse.emf.codegen.ecore.Generator$PlatformRunnable$1.r un(Generator.java:424)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1975)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1957)
at org.eclipse.emf.codegen.ecore.Generator$PlatformRunnable.run (Generator.java:458)
at org.eclipse.emf.codegen.ecore.Generator.run(Generator.java:1 17)
at org.eclipse.emf.ant.taskdefs.codegen.ecore.GeneratorTask.gen erateCodeFromGenModel(GeneratorTask.java:531)
at org.eclipse.emf.ant.taskdefs.codegen.ecore.GeneratorTask.doE xecute(GeneratorTask.java:394)
at org.eclipse.emf.ant.taskdefs.EMFTask.execute(EMFTask.java:76 )
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.j ava:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(Dispatch Utils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.ja va:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306 )
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(D efaultExecutor.java:41)
at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.exe cuteTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:118 9)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(Inte rnalAntRunner.java:662)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(Inte rnalAntRunner.java:495)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378)
at org.eclipse.ant.internal.launching.launchConfigurations.AntL aunchDelegate.runInSameVM(AntLaunchDelegate.java:321)
at org.eclipse.ant.internal.launching.launchConfigurations.AntL aunchDelegate.launch(AntLaunchDelegate.java:274)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:702)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:695)
at org.eclipse.core.externaltools.internal.model.ExternalToolBu ilder.launchBuild(ExternalToolBuilder.java:181)
at org.eclipse.core.externaltools.internal.model.ExternalToolBu ilder.doBuildBasedOnScope(ExternalToolBuilder.java:169)
at org.eclipse.core.externaltools.internal.model.ExternalToolBu ilder.build(ExternalToolBuilder.java:88)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildMan ager.java:629)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(Bui ldManager.java:172)
at org.eclipse.core.internal.events.BuildManager.basicBuild(Bui ldManager.java:203)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildMan ager.java:255)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(Bui ldManager.java:258)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop (BuildManager.java:311)
at org.eclipse.core.internal.events.BuildManager.build(BuildMan ager.java:343)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBu ildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJ ob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.emf.codegen.jet.JETException: ClassNotFoundException: org.eclipse.emf.codegen.ecore.templates.model.FactoryClass_
at org.eclipse.emf.codegen.jet.JETEmitter$EclipseHelper.initial ize(JETEmitter.java:883)
at org.eclipse.emf.codegen.jet.JETEmitter.initialize(JETEmitter .java:397)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.j ava:459)
at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAda pter.generateJava(AbstractGeneratorAdapter.java:981)
... 55 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.codegen.ecore.templates.model.FactoryClass_
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
at org.eclipse.emf.codegen.jet.JETEmitter$EclipseHelper$3.loadC lass(JETEmitter.java:841)
at org.eclipse.emf.codegen.jet.JETEmitter$EclipseHelper.initial ize(JETEmitter.java:861)
... 58 more

The affected class varies, though. In the log there are entries that report ValidatorClass_, XMLProcessorClass_, FactoryClass_, EnumClass_, or simply Class_ to be not found. So, apparently, this has to do with the generated .JETEmitters project.
Re: emf.Ecore2Java Ant task is flaky [message #646597 is a reply to message #646592] Wed, 29 December 2010 03:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Mirko,

It sounds like the generator is trying to load dynamic templates.
You're making use of dynamic templates? Maybe a task that removes the
hidden .JETEmitters project so it can be regenerated cleanly will help...


Mirko Raner wrote:
> Good point, Ed! I forgot that emf.Ecore2Java actually runs inside the
> IDE and did not check the workspace log.
> There are a couple of warnings like this in the log:
>
> org.eclipse.emf.common.util.WrappedException:
> org.eclipse.emf.codegen.jet.JETException: ClassNotFoundException:
> org.eclipse.emf.codegen.ecore.templates.model.FactoryClass_
> at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAda
> pter.generateJava(AbstractGeneratorAdapter.java:1112)
> at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageG
> eneratorAdapter.generateFactoryInterface(GenPackageGenerator
> Adapter.java:520)
> at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageG
> eneratorAdapter.generateModel(GenPackageGeneratorAdapter.jav a:220)
> at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGene
> ratorAdapter.doGenerate(GenBaseGeneratorAdapter.java:221)
> at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAda
> pter.generate(AbstractGeneratorAdapter.java:290)
> at org.eclipse.emf.codegen.ecore.generator.Generator.generate(G
> enerator.java:617)
> at org.eclipse.emf.codegen.ecore.generator.Generator.generate(G
> enerator.java:528)
> at org.eclipse.emf.codegen.ecore.Generator$PlatformRunnable$1.r
> un(Generator.java:424)
> at org.eclipse.core.internal.resources.Workspace.run(Workspace.
> java:1975)
> at org.eclipse.core.internal.resources.Workspace.run(Workspace.
> java:1957)
> at org.eclipse.emf.codegen.ecore.Generator$PlatformRunnable.run
> (Generator.java:458)
> at org.eclipse.emf.codegen.ecore.Generator.run(Generator.java:1 17)
> at org.eclipse.emf.ant.taskdefs.codegen.ecore.GeneratorTask.gen
> erateCodeFromGenModel(GeneratorTask.java:531)
> at org.eclipse.emf.ant.taskdefs.codegen.ecore.GeneratorTask.doE
> xecute(GeneratorTask.java:394)
> at org.eclipse.emf.ant.taskdefs.EMFTask.execute(EMFTask.java:76 )
> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.j ava:288)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.apache.tools.ant.dispatch.DispatchUtils.execute(Dispatch
> Utils.java:106)
> at org.apache.tools.ant.Task.perform(Task.java:348)
> at org.apache.tools.ant.Target.execute(Target.java:357)
> at org.apache.tools.ant.Target.performTasks(Target.java:385)
> at org.apache.tools.ant.Project.executeSortedTargets(Project.ja va:1337)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1306 )
> at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(D
> efaultExecutor.java:41)
> at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.exe
> cuteTargets(EclipseDefaultExecutor.java:32)
> at org.apache.tools.ant.Project.executeTargets(Project.java:118 9)
> at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(Inte
> rnalAntRunner.java:662)
> at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(Inte
> rnalAntRunner.java:495)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378)
> at org.eclipse.ant.internal.launching.launchConfigurations.AntL
> aunchDelegate.runInSameVM(AntLaunchDelegate.java:321)
> at org.eclipse.ant.internal.launching.launchConfigurations.AntL
> aunchDelegate.launch(AntLaunchDelegate.java:274)
> at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L
> aunchConfiguration.java:853)
> at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L
> aunchConfiguration.java:702)
> at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L
> aunchConfiguration.java:695)
> at org.eclipse.core.externaltools.internal.model.ExternalToolBu
> ilder.launchBuild(ExternalToolBuilder.java:181)
> at org.eclipse.core.externaltools.internal.model.ExternalToolBu
> ilder.doBuildBasedOnScope(ExternalToolBuilder.java:169)
> at org.eclipse.core.externaltools.internal.model.ExternalToolBu
> ilder.build(ExternalToolBuilder.java:88)
> at org.eclipse.core.internal.events.BuildManager$2.run(BuildMan
> ager.java:629)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at org.eclipse.core.internal.events.BuildManager.basicBuild(Bui
> ldManager.java:172)
> at org.eclipse.core.internal.events.BuildManager.basicBuild(Bui
> ldManager.java:203)
> at org.eclipse.core.internal.events.BuildManager$1.run(BuildMan
> ager.java:255)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at org.eclipse.core.internal.events.BuildManager.basicBuild(Bui
> ldManager.java:258)
> at org.eclipse.core.internal.events.BuildManager.basicBuildLoop
> (BuildManager.java:311)
> at org.eclipse.core.internal.events.BuildManager.build(BuildMan
> ager.java:343)
> at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBu
> ildJob.java:144)
> at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJ
> ob.java:242)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
> Caused by: org.eclipse.emf.codegen.jet.JETException:
> ClassNotFoundException:
> org.eclipse.emf.codegen.ecore.templates.model.FactoryClass_
> at org.eclipse.emf.codegen.jet.JETEmitter$EclipseHelper.initial
> ize(JETEmitter.java:883)
> at org.eclipse.emf.codegen.jet.JETEmitter.initialize(JETEmitter
> .java:397)
> at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.j ava:459)
> at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAda
> pter.generateJava(AbstractGeneratorAdapter.java:981)
> .. 55 more
> Caused by: java.lang.ClassNotFoundException:
> org.eclipse.emf.codegen.ecore.templates.model.FactoryClass_
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
> at org.eclipse.emf.codegen.jet.JETEmitter$EclipseHelper$3.loadC
> lass(JETEmitter.java:841)
> at org.eclipse.emf.codegen.jet.JETEmitter$EclipseHelper.initial
> ize(JETEmitter.java:861)
> .. 58 more
>
> The affected class varies, though. In the log there are entries that
> report ValidatorClass_, XMLProcessorClass_, FactoryClass_, EnumClass_,
> or simply Class_ to be not found. So, apparently, this has to do with
> the generated .JETEmitters project.
>
Re: emf.Ecore2Java Ant task is flaky [message #646683 is a reply to message #646597] Wed, 29 December 2010 21:14 Go to previous message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 82
Registered: July 2009
Location: New York City, NY
Member
Indeed we're making use of dynamic templates. However, that was used only as a work-around for bug 317549, which is fixed for EMF 2.6.1. Since our product requires Helios SR1 anyway, we removed the dynamic templates.
For now, it seems that this change has made the problem disappear (though, I can't be sure yet because the problem was pretty intermittent to begin with).

Thanks a lot for the hints! I'll report back if the issue reoccurs or other problems start popping up.
Previous Topic:Unable to load serialized data model
Next Topic:CDO Hibernate Store Example
Goto Forum:
  


Current Time: Sun Oct 20 16:18:53 GMT 2019

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

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

Back to the top