Skip to main content



      Home
Home » Modeling » Epsilon » Standalone from Java(Running it properly)
Standalone from Java [message #1080100] Mon, 05 August 2013 09:19 Go to next message
Eclipse UserFriend
Hello

I'm currently trying to integrate Epsilon scripts into a more general Java application.
I'v downloaded the sources and taken a look at the examples (in particular org.eclipse.epsilon.examples.standalone).

I have written a few classes inspired by this example that are supposed to do the exact same thing as the builtin "Launch configuration" in eclipse. However, I have some subtle differences when I run my module from Java:


  1. The application never stops
    After investigating, it happens only when I use collections in my script. It appears that a cache is created (org.eclipse.epsilon.eol.util.Cache). This one creates a disposal thread that is never stopped, it seems that the "dispose" method of the cache is never called. Since the thread is not daemon, the application hangs...

    What am I doing wrong? I'm already calling
    module.getContext().getModelRepository().dispose();
    So is there anything more to dispose?

  2. The cross-references use absolute path
    When I use the eclipse launch configuration, cross-references are serialized as a relative path. From java, it's an absolute path, which may be valid but is undesirable as Exeed and EMF editors don't understand it.
    I can't find a way to force using relative URI...



I attached to this post a minimal example of my code in case it helps. The example is quite complex already, sorry but that was necessary to expose the problems.

Best regards

[Updated on: Mon, 05 August 2013 09:20] by Moderator

Re: Standalone from Java [message #1080280 is a reply to message #1080100] Mon, 05 August 2013 14:33 Go to previous messageGo to next message
Eclipse UserFriend
Hi Gaetan,

I'm sorry to hear that you're having problems. Let's see:

1. The thread created by the Cache class is a daemon thread since SVN r2103 (December 2012), AFAIK. It is created from the createCleanUpThread method, which is only called from this code:

cleanUpThread = createCleanUpThread();
cleanUpThread.setDaemon(true);
cleanUpThread.start();


SVN r2103 is only available as an interim version, though. Are you using Epsilon 1.0 stable (November 2012), or an interim version? I think you should be able to fix this issue by simply upgrading to the latest interim.

The Cache is disposed from ExtendedProperties#clear(), and has nothing to do with the model repository. You can access the ExtendedProperties using module.getContext().getExtendedProperties(), but I think we should do this from the dispose() method of the EolContext anyway. Could you file a bug for this and add a link to this thread?

2. I'm not sure about this one, actually. There must be something going on in the launch configuration that is being set up differently to your standalone configuration. Could you add your run configuration to your example? Please remember that you need to use the "Common" tab in your launch configuration and use the "Save as > Shared file" option to save it into your project.

Kind regards,
Antonio
Re: Standalone from Java [message #1080655 is a reply to message #1080280] Tue, 06 August 2013 04:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi Antonio,

Thanks for your quick answer, here comes the launch configuration attached.
I am using the Epsilon 1.0 stable (November 2012) indeed.

Regarding question 1, what I don't understand is that the cache seems to be disposed properly when running from the launch configuration. So that must be something wrong on my behalf, not only a "daemon thread" problem. Not sure I should file a bug for that?

I also have another more general question regarding the example I sent:
In the ETL module, I use an operation that takes as argument an Enum literal. If I try to declare the type of the argument (OUT!ECommodityQuality), it fails with a "Type OUT!ECommodityQuality not found". Current workaround is to declare an untyped argument but I'd like to understand...
In particular, at line 19, I use this type without any problem => So what's wrong?

[Updated on: Tue, 06 August 2013 04:12] by Moderator

Re: Standalone from Java [message #1081517 is a reply to message #1080655] Wed, 07 August 2013 06:18 Go to previous messageGo to next message
Eclipse UserFriend
As far as I can see in the code, the dispose method of the Cache class was only called from EUnit until my recent commit (SVN r2358). It's now called from the EolContext#dispose() method as well. Nevertheless, it should be disposed automatically, as we use weak references in the cache so the Java garbage collector can clean it up when the EolModule is no longer reachable.

Again, I'd recommend trying the latest interim, as we've made quite a few changes in that area since 1.0. I've tried it with the latest SVN version on Kepler and your standalone program finishes its execution correctly with no issues.

Your problem with Enum literals is a known issue, I'm afraid. We've been looking into it, but fixing it would require a considerable reworking of a vital Epsilon class (AbstractEmfModel) and we're still thinking of how to do it without breaking existing code:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=286412

As for the absolute paths in the serialized models when running from Java: I have run your RunWorkflow#main method and it is generating relative paths for me. I'm using the latest SVN release (very close to the latest interim) on Kepler. Are you using 1.0 on Juno?

Edit: I've attached the two generated models.

[Updated on: Wed, 07 August 2013 06:24] by Moderator

Re: Standalone from Java [message #1081624 is a reply to message #1081517] Wed, 07 August 2013 09:24 Go to previous messageGo to next message
Eclipse UserFriend
Yes, I'm working on Epsilon 1.0 on Juno.
I may switch to an interim version but as I won't be working alone on my project, I prefer stitching to official releases for now.
Now that I know that those are not problems with my code and that it will be corrected in next release, I see no urge to switch.

Concerning the Enum literals in operations, i've voted for this "enhancement request". The workaround is easy but it may leave a bad impress to begginers to have such an unexpected restriction in the language, that would be a pity.

Thanks a lot for the quick answers.
Re: Standalone from Java [message #1083083 is a reply to message #1080100] Fri, 09 August 2013 08:53 Go to previous messageGo to next message
Eclipse UserFriend
[Sorry for the triple post, my browser did not print the new message]

[Updated on: Fri, 09 August 2013 11:21] by Moderator

Re: Standalone from Java [message #1083168 is a reply to message #1080100] Fri, 09 August 2013 11:18 Go to previous messageGo to next message
Eclipse UserFriend
[Sorry for the triple post, my browser did not print the new message]

[Updated on: Fri, 09 August 2013 11:21] by Moderator

Re: Standalone from Java [message #1083169 is a reply to message #1081624] Fri, 09 August 2013 11:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi Antonio,

I've run the minimal example on Kepler RC3 with Epsilon Interim (from the interim update site): the cache disposal issue is fixed indeed, but I still have the problem with absolute paths.

I've run validation of the output models through EMF validator and it gives me errors because of these absolute path: so the generated XMI is not valid...

I've issued a bug (#414766), I've given it a high priority since for my use case, that's a blocker situation (I need to reuse models outside epsilon). However feel free to downgrade it, especially if you think the bug is fixed in the current SVN.

By the way, what's your policy for integrating SVN updates to interim versions?
Cause I tried to re-build epsilon from SVN but it didn't work out-of-the-box. I must admit I haven't tried much further and would be willing to wait for a new interim version. When do you think that would happen?

Thanks
Kind regards,
Re: Standalone from Java [message #1085039 is a reply to message #1083169] Mon, 12 August 2013 07:18 Go to previous messageGo to next message
Eclipse UserFriend
Let me try out the instructions in your bug report first: I need to reproduce it before I can do anything about it Smile.

We don't really have a formal policy for producing new interim versions. Normally, we release new interim version after fixing important bugs or adding interesting features. We're in the process of releasing 1.1 currently, though.

Re: Standalone from Java [message #1085217 is a reply to message #1085039] Mon, 12 August 2013 11:53 Go to previous messageGo to next message
Eclipse UserFriend
I've found the problem: the way in which the Java code passed the model URI to Epsilon wasn't portable across Unix and Windows systems. It would work fine on Linux and Mac, but it would produce the absolute cross-references you mentioned in Windows.

I've detailed the fix for your Java code in the bug report. We've also fixed the examples to make sure nobody hits this issue again. Thanks for reporting this!
Re: Standalone from Java [message #1085259 is a reply to message #1085217] Mon, 12 August 2013 13:08 Go to previous messageGo to next message
Eclipse UserFriend
Many thanks for the quick fix, the thing was driving me crazy... and now it works perfectly!
Re: Standalone from Java [message #1086497 is a reply to message #1080100] Wed, 14 August 2013 05:19 Go to previous messageGo to next message
Eclipse UserFriend
I have been facing another problem with the project I sent at the begginning of the topic...

This time, the problem is with the model editor that doesn't behave well. I've filed a bug report (#415037) describing exactly my issue.

Could you tell me if you can reproduce it on linux or if it's a windows only bug?

IMHO it's rather a problem with the Package registry which I find quite unstable on my setup (see #414675for more details).

I'm quite good at tripping on stupid issues so I hope it's only something wrong in my configuration.

Thanks in advance Wink
Re: Standalone from Java [message #1087460 is a reply to message #1086497] Thu, 15 August 2013 13:26 Go to previous messageGo to next message
Eclipse UserFriend
After spending a few hours debugging Epsilon on bug 415037, it turned out it was a small issue on your .emf file. All the details are there: in short, you should always use URI-based imports instead of file-based imports in EMFatic files, or things can get nasty!

Please fix your .emf file and then report back on bug 414675.
Re: Standalone from Java [message #1087886 is a reply to message #1087460] Fri, 16 August 2013 04:25 Go to previous messageGo to next message
Eclipse UserFriend
Sorry that you lost your time on that one, it seems to be a rookie EMF mistake.

Concerning bug 414675, i've reported that it is not related.
However the problem remains: if I run a script with a fresh startup, the script won't work. I have to go to preferences->Epsilon EMF registry and click apply and then it works. Or I can register any EPackage and the registry starts working.
My belief is that the Registry doesn't get loaded automatically and that it needs some interaction to be initialized.

Maybe it's the expected behaviour and my bug report should be changed to an enhancement request?

[Updated on: Fri, 16 August 2013 04:26] by Moderator

Re: Standalone from Java [message #1087952 is a reply to message #1087886] Fri, 16 August 2013 06:42 Go to previous message
Eclipse UserFriend
I think it'd be better to continue the discussion on the bug report itself, to avoid duplicating information Smile.
Previous Topic:[EVL] Live Validation and EMF support
Next Topic:Eugenia creating nested Shape Figure
Goto Forum:
  


Current Time: Fri Nov 07 13:33:28 EST 2025

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

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

Back to the top