Open akshaygurao opened 3 years ago
I am experiencing the same problem when not using Graal. Trying to create a graph from nodes. When I have org.graalvm.js:js:21.0.0
dependency this code works as expected.
The version of the library: 0.18.0
Using those dependencies:
guru.nidi:graphviz-java:0.18.0
com.eclipsesource.j2v8:j2v8_win32_x86_64:4.6.0
val g: Graph = graph("example1").directed()
.graphAttr().with(Rank.dir(Rank.RankDir.LEFT_TO_RIGHT))
.nodeAttr().with(Font.name("arial"))
.linkAttr().with("class", "link-class")
.with(nodes)
Graphviz.useEngine(GraphvizV8Engine(), GraphvizJdkEngine())
Graphviz.fromGraph(g).height(700).render(Format.PNG)
.toFile(File("graph/g${(0..45664564).random()}.png"))
Stacktrace:
Exception in thread "DefaultDispatcher-worker-3" guru.nidi.graphviz.engine.GraphvizException: Problem executing javascript
at guru.nidi.graphviz.engine.NashornJavascriptEngine.eval(NashornJavascriptEngine.java:57)
at guru.nidi.graphviz.engine.NashornJavascriptEngine.execute(NashornJavascriptEngine.java:49)
at guru.nidi.graphviz.engine.AbstractJavascriptEngine.executeJavascript(AbstractJavascriptEngine.java:23)
at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.measureFonts(AbstractJsGraphvizEngine.java:118)
at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.jsVizExec(AbstractJsGraphvizEngine.java:104)
at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.execute(AbstractJsGraphvizEngine.java:96)
at guru.nidi.graphviz.engine.Graphviz.doExecute(Graphviz.java:312)
at guru.nidi.graphviz.engine.Graphviz.execute(Graphviz.java:292)
at guru.nidi.graphviz.engine.Renderer.execute(Renderer.java:139)
at guru.nidi.graphviz.engine.Renderer.toFile(Renderer.java:59)
at ru.eastbanctech.mysterypassenger.MainKt.drawGraph(Main.kt:102)
at ru.eastbanctech.mysterypassenger.MainKt.showSurveys(Main.kt:79)
at ru.eastbanctech.mysterypassenger.MainKt.access$showSurveys(Main.kt:1)
at ru.eastbanctech.mysterypassenger.MainKt$main$1.invokeSuspend(Main.kt:37)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:188)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:144)
at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:15)
at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:90)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:188)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:144)
at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:15)
at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:90)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: javax.script.ScriptException: TypeError: Float64Array.from is not a function in <eval> at line number 404
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at guru.nidi.graphviz.engine.NashornJavascriptEngine.eval(NashornJavascriptEngine.java:55)
... 29 more
Caused by: <eval>:404 TypeError: Float64Array.from is not a function
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
at jdk.nashorn.internal.runtime.Undefined.lookup(Undefined.java:102)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:106)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at jdk.nashorn.internal.scripts.Script$Recompilation$1004$2413178AAA$\^eval\_.L:345#setFontWidth(<eval>:404)
at jdk.nashorn.internal.scripts.Script$Recompilation$1003$3812AA$\^eval\_.L:26#ModuleWrapper#setFontWidth(<eval>:129)
at jdk.nashorn.internal.scripts.Script$Recompilation$1002$8574AA$\^eval\_.L:26#Viz#setFontWidth(<eval>:265)
at jdk.nashorn.internal.scripts.Script$1001$\^eval\_.:program(<eval>:1)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
... 33 more
I cannot reproduce it. Which OS and Java version do you use?
Hi,
I have the same exception on Windows 10
/ JDK 1.8.0_121
If I switch to JDK 11.0.5
the exception is not thrown anymore, but I have a strong requirement on using JDK 1.8
...
Using those dependencies:
guru.nidi:graphviz-java:0.18.1
com.eclipsesource.j2v8:j2v8_win32_x86_64:4.6.0
I also got this error when adding graphAttrs().add(Font.name("arial"))
to the graph
Hello, @nidi3
I faced the same problem on MacOS 12.4
(Apple M1 / aarch64).
Need to generate DB schema with SchemaCrawler
and Graphviz
.
I made a test project and used the GraalJS
as the engine. It works.
Then I tried Nashorm
engine to compare speed and got the error.
Formats: SVG
, PNG
, PS
.
versions:
SchemaCrawler - 16.16.14
Graphviz - 0.18.1
I've tried 2 JDKs:
OpenJDK Runtime Environment (Zulu 8.58.0.13-CA-macos-aarch64) (build 1.8.0_312-b07)
OpenJDK Runtime Environment Zulu11.52+13-CA (build 11.0.13+8-LTS)
So the situation in my case: SchemaCrawler
generates Dot-file which is then passed to Graphviz
. Graphviz
transforms it to JS.
I debugged all that carefully and extracted the JS code. Exception is thrown on line 404.
403| function setFontWidth(instance, name, widths) {
404| var typedArray = Float64Array.from(widths);
SchemaCrawler code which calls Graphviz:
Graphviz.useEngine(engines);
...
Graphviz.fromString(dotSource).render(format).toFile(outputFile.toFile());
So I attached my Dot-file and generated JS code. 0fddb7ff-ec0f-4f9f-8996-9f622c73a986.dot.txt script1.js.txt
Trying to use this library for converting dot file to PNG. Below is the code snippet.
Error -
Please let me know if I am missing some dependencies or configurations.