Layouting with version 0.8.1 errors when run in a jar build by gradle
I recently tried upgrading my ELK-core and alg.layered dependencies from 0.7.1 to 0.8.1. Everything was working in 0.7.1 even when ELK was run in a docker container.
However, after upgrading to 0.8.1 layouting still works when run on my windows 10 machine directly but throws the following error when invoked inside a docker container:
org.eclipse.elk.core.UnsupportedConfigurationException: Unable to load default layout algorithm org.eclipse.elk.layered for unconfigured node Root Node
at org.eclipse.elk.core.data.LayoutAlgorithmResolver.resolveAlgorithm(LayoutAlgorithmResolver.java:61) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.data.LayoutAlgorithmResolver.visit(LayoutAlgorithmResolver.java:28) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.util.ElkUtil.applyVisitors(ElkUtil.java:1018) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(RecursiveGraphLayoutEngine.java:92) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(RecursiveGraphLayoutEngine.java:72) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
...
Maybe there was a change in accessing the default configuration in the new version?
Thanks in advance, and let me know if you need further information.
~~This might be related to https://github.com/eclipse/elk/issues/651~~. Do you have an example configuration where this occurred?
I simply use the following two lines in my program to lay out a previously created graph:
RecursiveGraphLayoutEngine recursiveGraphLayoutEngine = new RecursiveGraphLayoutEngine();
recursiveGraphLayoutEngine.layout(layoutGraph, new BasicProgressMonitor());
Ok, which graph specifically? I need that to reproduce the problem.
I create the graph using:
ElkNode layoutGraph = ElkGraphUtil.createGraph();
Later I create some nodes and edges for this graph:
ElkGraphUtil.createNode(layoutGraph);
...
ElkGraphUtil.createSimpleEdge(sourceLayoutNode, targetLayoutNode);
So you are using elk in plain java. You create the graph programmatically via ElkGraphUtil and in this setup any graph triggers the error, correct?
Yes, when the code is executed in a docker container (not if the resulting jar is run on windows).
Have you checked release notes? Are you relying on extension points to register the layout algorithms or does the service loader not work in the docker container?
I got a new but similar exception when configuring the layout algorithm explicitly:
org.eclipse.elk.core.UnsupportedConfigurationException: Layout algorithm 'org.eclipse.elk.layered' not found for Root Node
at org.eclipse.elk.core.data.LayoutAlgorithmResolver.resolveAlgorithm(LayoutAlgorithmResolver.java:70) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.data.LayoutAlgorithmResolver.visit(LayoutAlgorithmResolver.java:28) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.util.ElkUtil.applyVisitors(ElkUtil.java:1018) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(RecursiveGraphLayoutEngine.java:92) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(RecursiveGraphLayoutEngine.java:72) ~[org.eclipse.elk.core-0.8.1.jar!/:na]
at groove.GrooveGxlHelper.layoutGraph(GrooveGxlHelper.java:97) ~[ruleGenerator-1.jar!/:na]
It seems to be a problem whenever ELK is invoked in my JAR-File (not docker related, as I thought earlier). I used Gradle to build my JAR and add ELK + the layered algorithm I am using as follows:
// https://mvnrepository.com/artifact/org.eclipse.elk/org.eclipse.elk.core
implementation 'org.eclipse.elk:org.eclipse.elk.core:0.8.1'
// https://mvnrepository.com/artifact/org.eclipse.elk/org.eclipse.elk.alg.layered
implementation 'org.eclipse.elk:org.eclipse.elk.alg.layered:0.8.1'
To replicate the issue, download this jar and run it.
Then go to localhost:8080 and click the following button:

Somehow, the new ELK version cannot find the layered layout algorithm in the latest version.
How are you registering your layout algorithms? The KlighD project does it like this. I don't use the plain java setup very often, maybe this will also help or the corresponding discussion in Klighd.
Using the old ELK version, I did not set anything at all. I just called
RecursiveGraphLayoutEngine recursiveGraphLayoutEngine = new RecursiveGraphLayoutEngine();
recursiveGraphLayoutEngine.layout(layoutGraph, new BasicProgressMonitor());
as described earlier, which works if I start my program through the IDE but not when used in a JAR. The default layout algorithm used was "org.eclipse.elk.layered". Now, I set this explicitly as so:
layoutGraph.setProperty(CoreOptions.ALGORITHM, "org.eclipse.elk.layered");
The layout graph is the root node. The layout algorithm should be provided by the Gradle dependency shown above.
Sadly I currently have no idea why this is happening and what changed to cause this. My only clue was that the layoutProvider extension point was removed (which you do not use as far as I understand) and that other applications register their different layout providers.
Thanks either way for looking at the issue. Maybe I or someone else will find a solution in the future.
I just had to add
LayoutMetaDataService.getInstance().registerLayoutMetaDataProviders(new LayeredMetaDataProvider());
which wasn't necessary before 0.8.1.