Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] template/generation error listening(other than watching STDOUT)
[Acceleo] template/generation error listening [message #917733] Thu, 20 September 2012 11:30 Go to next message
Joel Gluth is currently offline Joel GluthFriend
Messages: 5
Registered: May 2012
Junior Member
I have a relatively large Acceleo component that functions as a Maven plugin. It's pretty useful, but one of the things that would make it better is having my Maven build fail if generation raises exceptions.

For example,

org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 46 in Module java for block for (getOwnedContraintInPackage(ownedAttribute,Bag {'constraints'})). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.PropertyImpl@484d3500 (name: searchTerm, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false, isDerivedUnion: false, aggregation: none). Problem found while generating the file 'D:\Projects\whatever-proxy\target\generated-sources\java\com\whatever\forms\SomethingSearchForm.java'.
        at java.generateValidationConstraints(Property)(java.mtl:46)
        at java.generateValidationConstraints(Property)(java.mtl:45)


turns up in my STDOUT, and is definitely a failure. However, I can't find a way to listen for this happening - no exception gets thrown to or by my Generate class, which I'm wrapping in the Maven task.

Monitor and IAcceleoTextGenerationListener do not seem to have quite the capacity I want, though it's entirely possible I'm reading the API wrong.

How can I listen for these kinds of event?

[Updated on: Thu, 20 September 2012 15:19]

Report message to a moderator

Re: [Acceleo] template/generation error listening [message #923785 is a reply to message #917733] Wed, 26 September 2012 07:37 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

In order to react to those events, I think you would need to provide your own IAcceleoEngine (you could delegate all the behavior back to the original engine). As for your error, I would say that the operation returning the collection used by the for loop returned null or something that could not be casted in the type of your iterator.


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo] template/generation error listening [message #926053 is a reply to message #923785] Fri, 28 September 2012 09:03 Go to previous messageGo to next message
Joel Gluth is currently offline Joel GluthFriend
Messages: 5
Registered: May 2012
Junior Member
Yeah, I had come to the same conclusion, which is not so terrible, it just takes a little time.

As for the specific error, it was just an example - fixing it wasn't too hard.

Thanks for the reply!
Re: [Acceleo] template/generation error listening [message #1005765 is a reply to message #917733] Mon, 28 January 2013 16:29 Go to previous messageGo to next message
Joel Gluth is currently offline Joel GluthFriend
Messages: 5
Registered: May 2012
Junior Member
Apologies for the thread necromancy, but Acceleo has become topical for me again and I'm actually going to have to make this happen.

The suggestions itself is fine as far as it goes. The problem for me is ensuring the creation of the different AcceleoEngine implementation... my Generate class can override AbstractGenerator's createAcceleoService() method to get an AcceleoService (which is the class that actually manages the IAcceleoEngine). However, AcceleoService itself is mostly private, the class is final, and it does not implement an interface.

In particular, this bit is problematic:

    private void createEngine() {
        if (EMFPlugin.IS_ECLIPSE_RUNNING) {
            generationEngine = new DefaultEngineSelector().selectEngine(AcceleoEngineRegistry
                    .getRegisteredCreators());
        }
        if (generationEngine == null) {
            generationEngine = new AcceleoEngine();
        }
    }


While IAcceleoEngine seems nice and extensible, the generator task has to access it through a layer that cannot be changed and which dictates the implementation of IAcceleoEngine when I am running outside Eclipse. Which is definitely where I am, with my standalone task!

Or does EMFPlugin.IS_ECLIPSE_RUNNING not do what it seems to do?

[Updated on: Mon, 28 January 2013 16:30]

Report message to a moderator

Re: [Acceleo] template/generation error listening [message #1005938 is a reply to message #1005765] Tue, 29 January 2013 10:59 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

You are indeed right, in stand alone you will need to change AcceleoService to provide a custom engine.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks
Re: [Acceleo] template/generation error listening [message #1005979 is a reply to message #1005938] Tue, 29 January 2013 13:15 Go to previous messageGo to next message
Joel Gluth is currently offline Joel GluthFriend
Messages: 5
Registered: May 2012
Junior Member
Since AcceleoService is final, and its methods are mostly private anyway, my choices become

1. Fork Acceleo (I don't like this idea much) and alter AcceleoService directly, or
2. have my Generate class use something that is almost exactly an AcceleoService in terms of function and code, but isn't an AcceleoService (in the OO sense).

Neither of these is wonderful, given that there has been helpful effort in Acceleo to provide interfaces like IAcceleoEngine and AbstractGenerator and so on to allow extensibility. But I will do the second one Smile

Out of interest, why is AcceleoService final?

[edit: looking at it, my idea won't work; too many parts of the Acceleo code take an AcceleoService argument explicitly when they are called from Generate. Hmm. Alternatively I can have just the parts of Generate that call AcceleoService, which in turn delegates to the Engine, do... something different.]

[Updated on: Tue, 29 January 2013 13:31]

Report message to a moderator

Re: [Acceleo] template/generation error listening [message #1009510 is a reply to message #1005979] Fri, 15 February 2013 08:56 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Joel,

Within Eclipse, you can locate the LogView and add log listeners to react to them.
Outside of Eclipse, we log errors on System.err (http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git/tree/plugins/org.eclipse.acceleo.engine/src/org/eclipse/acceleo/engine/AcceleoEnginePlugin.java#n73). The exception is not thrown "out" of Acceleo as long as it is not fatal. Furthermore, most exceptions won't even stop the generation. What you pasted in the first post of this thread is an example of such an exception : we failed on one template, but we can still continue to generate for the rest.

AcceleoService is final since it was simply not designed to be extended. This class is only meant as an interface between the client code and the generation engine, in order to avoid rewriting all the boilerplate code. Replacing the engine is something that is rarely necessary, and since it is sufficiently rare, we decided not to spend time trying to make it easier. You will have to copy/paste the "AcceleoService#doGenerate(...)" method that is closest to what you seek to do, and replace the default AcceleoEngine we call by your own instance.

This is something we have never needed to do, and as such some necessary methods may be internal, don't hesistate to raise enhancement requests if you hit a wall Smile.

Laurent Goubet
Obeo
Re: [Acceleo] template/generation error listening [message #1715869 is a reply to message #1009510] Thu, 26 November 2015 19:41 Go to previous messageGo to next message
Prashant Gupta is currently offline Prashant GuptaFriend
Messages: 1
Registered: November 2015
Junior Member
Hello,

I am facing similar type of problem. I want to throw any Exception that happens in acceleo code template to my Generate class, and through that to my calling class, so as I can show error on UI screen.

But i am unable to find any way to capture those exceptions.
Pl help.

Thanks in advance.

Prashant Gupta
Re: [Acceleo] template/generation error listening [message #1716061 is a reply to message #1715869] Mon, 30 November 2015 22:13 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

Your problem seems nothing to do with the earlier thread, so it is very
difficult to answer.

Generally Java is quite flexible about throwing and catching exceptions,
so what is your problem?

Regards

Ed Willink


On 30/11/2015 20:16, Prashant Gupta wrote:
> Hello,
>
> I am facing similar type of problem. I want to throw any Exception that
> happens in acceleo code template to my Generate class, and through that
> to my calling class, so as I can show error on UI screen.
> But i am unable to find any way to capture those exceptions.
> Pl help.
>
> Thanks in advance.
>
> Prashant Gupta
Previous Topic:[Acceleo] How to register other metamodels?
Next Topic:How the use 2 input Models in Acceleo
Goto Forum:
  


Current Time: Thu Dec 12 14:24:01 GMT 2024

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

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

Back to the top