Contextmapper generator crash when generating plantuml for contextmap with an imported bounded context file.
Describe the bug The contextmapper cli crashes when asked to generate plantuml files for a contextmap which includes an import of another CML file. That other CML file contains the bounded contexts implementing the domains.
To Reproduce Steps to reproduce the behavior:
- As a simple test to isolate the problem I reproduced this issue using the CML "example" code shown on the ContextMapper website in https://contextmapper.org/docs/imports/. It uses two files, a ContextMap.cml and a BoundedContexts.cml file.
- Run the command "cm generate -g plantuml -i ContextMap.cml -o src-gen"
Expected behavior No crash and plantuml files for the aggregate and entities as well.
Screenshots / Exceptions
Context Mapper CLI v6.12.0
Exception in thread "main" java.lang.IllegalArgumentException: resolve against non-hierarchical or relative base
at org.eclipse.emf.common.util.URI$Hierarchical.resolve(URI.java:3548)
at org.eclipse.emf.common.util.URI.resolve(URI.java:5580)
at org.contextmapper.dsl.cml.CMLImportResolver.resolveImportedResources(CMLImportResolver.java:42)
at org.contextmapper.dsl.cml.CMLModelDomainAndSubdomainResolver.initAllDeclaredSubdomainsIncludingImportedOnes(CMLModelDomainAndSubdomainResolver.java:87)
at org.contextmapper.dsl.cml.CMLModelDomainAndSubdomainResolver.
Input files to reproduce See attached. BoundedContexts.cml.txt ContextMap.cml.txt
IDE and Plugin (please complete the following information):
- Context Mapper CLI v6.12.0
- Visual studio Context Mapper v6.12.0
Additional context The visual studio plugin does not crash, however it only produces one plantuml file for the contextmap and does not produce any plantuml output for the aggregate/entities. Hence, it seems to fail parsing the imported file.
Thanks for reporting it @rerunner! We will try to reproduce and investigate...
Best regards, Stefan
@stefan-ka
The crash can be fixed with
line 55 in GenerateCommand
CMLResource cmlResource = cmAPI.loadCML( URI.createFileURI( new File(inputPath).getAbsolutePath() ).toString() );
I have a branch prepared which
- changes the global scope provider (reason for plantuml diagram showing only "null" as name)
- changes the reference validation for domain objects in workbench context. Import files will validate now, if the context-map exists in the same project.
I started the branch for the last topic and discovered that this issue is connected. Problem is, my branch started on a merge of pull request #366 and touches not only this issue.
I'm currently enjoying holidays without computer besides my phone, I can try what @astmuc mentioned, but only in 2 weeks from now. Have a good change of the year!
The crash can be fixed with line 55 in GenerateCommand
CMLResource cmlResource = cmAPI.loadCML( URI.createFileURI( new File(inputPath).getAbsolutePath() ).toString() );I have a branch prepared which
* changes the global scope provider (reason for plantuml diagram showing only "null" as name) * changes the reference validation for domain objects in workbench context. Import files will validate now, if the context-map exists in the same project.I started the branch for the last topic and discovered that this issue is connected. Problem is, my branch started on a merge of pull request #366 and touches not only this issue.
I tried this fix, it avoids the crash. However, it is not enough to produce plantuml files for the aggregate and entities that are located at the "imported" files, they still get ignored.
Hi @rerunner
I am aware that the whole importing mechanism is one of the least mature. We are happy to receive PRs if you like to contribute.
Best regards, Stefan