ModelDriven / Alf-Reference-Implementation

Open-source implementation of the Action Language for fUML (Alf) specification.
30 stars 2 forks source link

Can't open UML models compiled by alfc in Alf Reference Implementation in Eclipse #100

Closed alperkocatas closed 2 years ago

alperkocatas commented 2 years ago

I have imported the projects for version 1.1.0k of Alf Reference Implementation in Eclipse Modeling 2021-03 version.

I can use alfc launch configuration within Eclipse to compile org.modeldriven.alf\Models\Hello.alf. Compilation terminates successfully, and Hello.uml is written on file org.modeldriven.alf.eclipse/UML/Hello.uml.

However, when I try to upen Hello.uml file using the UML Model editor in Eclipse, I receive an error immediately after I expand Hello.

Error is as following: Problems encountered in file "pathmap://ALF_LIBRARIES/Alf.library.uml" MalformedURLException: unknown protocol: pathmap

Apparently, the package imports like the following which use the pathmap ALF_LIBRARIES are not recognized.

`

</packageImport>`

If I am supposed to register ALF_LIBRARIES as a new pathmap into Eclipse environment? I could not find a way to do that, either.

I am attaching a screenshot of the actual error.

image

I am trying this in the following environment:

  • Windows 10 arch: amd64
  • Eclipse Modeling 2021-03, with Papyrus software designer 2.0.0 and Moka 4.1.1 installed using marketplace.
  • java version 11.0.13 (Oracle)
  • default locale: en_US, encoding: cp1254

Note: I am not sure if this is the right place to ask for help about this issue, but since I could not reach a dedicated forum regarding Alf, I am entering it as an issue here. I would gladly carry this to any place which is more appropriate if you can guide me about it.

seidewitz commented 2 years ago

While pathmaps are a common mechanism in Eclipse, I don't know of any way to get the UML model editor to recognize pathmaps other than the hardcoded ones it knows. While these errors are annoying when viewing the .uml file in the editor, the XMI is actually otherwise well formed, so you can just ignore the errors as best you can.

If you want to programmatically load a resource with pathmaps, then you first need to put your local URIs for the pathmaps into the uriMap for your resource set. You can see an example of this in the org.modeldriven.alf.eclipse.units.RootNamespace::setLibraryDirectory method.

alperkocatas commented 2 years ago

Thanks for your answer. I am trying to use Alf and fuml for my Phd thesis, in which I am working on associating some kind of behaviors for UML connectors. I was hoping to embed alf statements inside a UML model which includes connectors and ports, to specify the behavior for the connectors. Therefore, it would be nice to be able to open UML models compiled from alf specifications from inside eclipse.

Yes, even if I can't navigate them fully using the embedded UML editor inside Eclipse, I can execute the UML models using the provided fuml launch configuration from inside eclipse. However, when trying that, I stumbled on another problem. I have a windows machine and macos machine which I need to work on simultaneously. It executes fine on macos, however, on the windows machine, I get the following exception when I try to execute Hello.uml using fuml launch configuration:

"Cannot create a resource for 'c:\Users\akocatas\Documents\AlfRefImp-1.1.0k\org.modeldriven.alf.eclipse\UML/Hello'; a registered resource factory is needed".

The exception is caused by this line in RootNamespaceImpl.java in package org.modeldriven.alf.eclipse.units:

Resource resource = this.resourceSet.getResource(uri, true);

within the method:

Resource getResource(URI uri) {...}

I could not fix this error by modifying the code (e.g. by adding a resource factory manually).

I tried to install exact same eclipse version and plugins in both windows and macos. Are the launch configurations tested on windows?

seidewitz commented 2 years ago

To be honest, this has not been tested on Windows lately. But I have now tracked down the cause of the problem.

It seems that, in Windows, Eclipse passes in the drive letter at the start of absolute paths. Such a path is passed in for the container directory of the selected resource when using the fuml launch configuration. This results in the URI not being correctly constructed for the target resource, which leads to the error you reported.

Until this bug is corrected, you can get around the problem on Windows by selecting Run > Run Configurations..., choosing fuml under Java Application and, in the Arguments tab, changing -u "${container_loc}" to -u "../org.modeldriven.alf.eclipse/UML". That is assuming that you are running a file in the UML directory. If you are using another directory, put that in the configuration.

alperkocatas commented 2 years ago

Modifying the -u argument as "../org.modeldriven.alf.eclipse/UML" has resolved the issue.

When using ${containter_loc} I have also observed from the debugger that c:has been misinterpreted as the "scheme" of the url. That does not happen when using the relative path.

I am closing the current issue. Thanks a lot.