Failed to retrieve the list of available macros (Failed to execute the [velocity] macro)

As the title says I can’t open the macro list. I tried looking through the older posts, but none of them looked like they were caused by the same error.

In this case it’s a fresh install of XWiki 13.10.9 using the official docker image xwiki:lts-mariadb-tomcat

I’m getting the following response when opening the menu, but I’m afraid I’m not familiar enough with Java to properly decipher it beyond just knowing something is missing.
macro-error.txt (31.4 KB)

Seems it could be related to the Kroki macro from what I see. It seems that the macro list (I suppose you’re referring to the Macro list in the WYSIWYG editor) is not protected against errors from macro component initialization.

For easy reading, here’s the error:

...
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getMacroDescriptors' in  class org.xwiki.rendering.script.RenderingScriptService threw exception org.xwiki.rendering.macro.MacroLookupException: Failed to lookup Macros at xwiki:CKEditor.MacroService[line 39, column 47]
	at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:308)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:235)
	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:368)
	at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:704)
	at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:75)
	at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:242)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:147)
	at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:218)
	at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:331)
	at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:261)
	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:304)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:147)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:171)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:147)
	at org.apache.velocity.runtime.parser.node.ASTElseIfStatement.render(ASTElseIfStatement.java:108)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:190)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:439)
	at org.apache.velocity.Template.merge(Template.java:358)
	at org.apache.velocity.Template.merge(Template.java:262)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:280)
	... 221 more
Caused by: org.xwiki.rendering.macro.MacroLookupException: Failed to lookup Macros
	at org.xwiki.rendering.internal.macro.DefaultMacroManager.getMacroIds(DefaultMacroManager.java:89)
	at org.xwiki.rendering.script.RenderingScriptService.getMacroDescriptors(RenderingScriptService.java:271)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:571)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:554)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:221)
	... 239 more
Caused by: org.xwiki.component.manager.ComponentLookupException: Failed to lookup component with type [interface org.xwiki.rendering.macro.Macro] and hint [kroki]
	at org.xwiki.component.embed.EmbeddableComponentManager.getInstanceMap(EmbeddableComponentManager.java:245)
	at org.xwiki.component.embed.EmbeddableComponentManager.getInstanceMap(EmbeddableComponentManager.java:253)
	at org.xwiki.component.internal.multi.DelegateComponentManager.getInstanceMap(DelegateComponentManager.java:95)
	at org.xwiki.component.internal.multi.DelegateComponentManager.getInstanceMap(DelegateComponentManager.java:95)
	at org.xwiki.component.internal.multi.DelegateComponentManager.getInstanceMap(DelegateComponentManager.java:95)
	at org.xwiki.component.internal.multi.DelegateComponentManager.getInstanceMap(DelegateComponentManager.java:95)
	at org.xwiki.component.internal.multi.DelegateComponentManager.getInstanceMap(DelegateComponentManager.java:95)
	at org.xwiki.rendering.internal.macro.DefaultMacroManager.getMacroIds(DefaultMacroManager.java:87)
	... 247 more
Caused by: org.xwiki.component.manager.ComponentLookupException: Failed to lookup component [org.xwiki.contrib.kroki.internal.rendrer.KrokiDiagramRenderer] identified by type [interface org.xwiki.contrib.kroki.renderer.DiagramRenderer] and hint [default]
	at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:204)
	at org.xwiki.component.embed.EmbeddableComponentManager.getDependencyInstance(EmbeddableComponentManager.java:406)
	at org.xwiki.component.embed.EmbeddableComponentManager.createInstance(EmbeddableComponentManager.java:355)
	at org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:451)
	at org.xwiki.component.embed.EmbeddableComponentManager.getInstanceMap(EmbeddableComponentManager.java:242)
	... 254 more
Caused by: org.xwiki.component.phase.InitializationException: Failed to initialize the Docker container for diagram rendering.
	at org.xwiki.contrib.kroki.internal.rendrer.KrokiDiagramRenderer.initializeKrokiDockerContainer(KrokiDiagramRenderer.java:151)
	at org.xwiki.contrib.kroki.internal.rendrer.KrokiDiagramRenderer.initializeKrokiComponent(KrokiDiagramRenderer.java:174)
	at org.xwiki.contrib.kroki.internal.rendrer.KrokiDiagramRenderer.initialize(KrokiDiagramRenderer.java:76)
	at org.xwiki.component.embed.InitializableLifecycleHandler.handle(InitializableLifecycleHandler.java:39)
	at org.xwiki.component.embed.EmbeddableComponentManager.createInstance(EmbeddableComponentManager.java:365)
	at org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:451)
	at org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:201)
	... 258 more
Caused by: java.lang.RuntimeException: java.io.IOException: com.sun.jna.LastErrorException: [2] No such file or directory
	at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:195)
	at com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:9)
	at com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
	at com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:202)
	at com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:74)
	at com.github.dockerjava.core.exec.ListContainersCmdExec.execute(ListContainersCmdExec.java:44)
	at com.github.dockerjava.core.exec.ListContainersCmdExec.execute(ListContainersCmdExec.java:15)
	at com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
	at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
	at org.xwiki.contrib.kroki.internal.docker.ContainerManager.exec(ContainerManager.java:310)
	at org.xwiki.contrib.kroki.internal.docker.ContainerManager.maybeReuseContainerByName(ContainerManager.java:96)
	at org.xwiki.contrib.kroki.internal.rendrer.KrokiDiagramRenderer.initializeKrokiDockerContainer(KrokiDiagramRenderer.java:135)
	... 264 more
Caused by: java.io.IOException: com.sun.jna.LastErrorException: [2] No such file or directory
	at com.github.dockerjava.transport.DomainSocket.<init>(DomainSocket.java:63)
	at com.github.dockerjava.transport.LinuxDomainSocket.<init>(LinuxDomainSocket.java:41)
	at com.github.dockerjava.transport.DomainSocket.get(DomainSocket.java:140)
	at com.github.dockerjava.transport.UnixSocket.get(UnixSocket.java:29)
	at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:153)
	at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
	at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:407)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:168)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:178)
	at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:136)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
	at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:165)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
	at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
	at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:133)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
	at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:179)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
	at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:191)
	... 275 more
Caused by: com.sun.jna.LastErrorException: [2] No such file or directory
	at com.github.dockerjava.transport.LinuxDomainSocket.connect(Native Method)
	at com.github.dockerjava.transport.LinuxDomainSocket.connect(LinuxDomainSocket.java:49)
	at com.github.dockerjava.transport.DomainSocket.open(DomainSocket.java:69)
	at com.github.dockerjava.transport.DomainSocket.<init>(DomainSocket.java:59)
	... 300 more

FTR I could reproduce.

Screenshot 2022-09-20 at 16.17.50

I’ve created [CKEDITOR-489] Don't fail the UI when a rogue macro is installed - XWiki.org JIRA

That was indeed the error, thank you very much :grin:

I could’ve sworn I’d already tried to uninstall Kroki as I was suspecting it, but I must have missed something.

Anyway have a nice day and thank you for the help.

I faced the same issue after installing the Kroki macro.
First I thought that the uninstall didn’t fix it, but there was actually a second extension installed as a dependency which I missed to uninstall:
image
After removing that one, the problem was fixed :slight_smile:

1 Like

Caused by: com.sun.jna.LastErrorException: [2] No such file or directory

This usually means your setup doesn’t support “Docker outside of Docker” (DooD). The Kroki macro needs to create and communicate with Docker containers (that add support for various diagram formats) which means:

  • The Docker host needs to be exposed inside the XWiki Docker container, and this is done by exposing the Docker socket /var/run/docker.sock
  • XWiki needs to have permission to use the Docker socket (i.e. the OS user running XWiki needs to be able to access the Docker socket).

Note that you’ll have a similar problem if you try to use the Docker-based PDF export, although that won’t break the macro list in the WYSIWYG editor.

Hope this helps,
Marius

Hi,

was also try … or better, now I’m able to use kroki plugin in xwiki-docker-compose setup without docker socket (dind).

Here my steps to make it work.

  1. Add the default Kroki docker to your docker-compose setup (expose port to host :/) - start kroki
  2. Install Kroki plugin
  3. go to the default kroki config /bin/edit/XWiki/Kroki/Default
  4. Add all supported DIAGRAM Types to the list, the menu in the macro is listing somehow the list from the API, but when not define here and used in the macro … it will try to start again a docker instance.
  5. Use TLS: NO
  6. HOST: IP-address from host (container name was somehow result in timeouts)
  7. PORT: need to be set, strange … but when not defined, some request had IP:null (so looks some config issues?)
  8. Health Check Path: /health, don’t know if needed. But have define it.
  9. Save the config

Hope to help someone also facing issues and can’t find a good documentation on how to setup. But this page was my first search result for the issue.