nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
934 stars 107 forks source link

J2V8 native library not loaded Only on Linux #219

Closed aetasoul closed 2 years ago

aetasoul commented 3 years ago

Hi @nidi3, I'm developing on windows and the application is deployed on linux server.

4.15.0-147-generic #151-Ubuntu SMP Fri Jun 18 19:21:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

My pom file contain:

<dependency>
  <groupId>guru.nidi</groupId>
  <artifactId>graphviz-java-all-j2v8</artifactId>
  <version>0.18.1</version>
</dependency>

I get this error only on the linux machine:

[http-nio-8080-exec-9] INFO guru.nidi.graphviz.engine.V8JavascriptEngine - Starting V8 runtime...
[http-nio-8080-exec-9] INFO guru.nidi.graphviz.engine.AbstractGraphvizEngine - Could not initialize guru.nidi.graphviz.engine.GraphvizV8Engine
java.lang.IllegalStateException: J2V8 native library not loaded
        at com.eclipsesource.v8.V8.checkNativeLibraryLoaded(V8.java:195)
        at com.eclipsesource.v8.V8.createV8Runtime(V8.java:149)
        at guru.nidi.graphviz.engine.V8JavascriptEngine.<init>(V8JavascriptEngine.java:36)
        at guru.nidi.graphviz.engine.GraphvizV8Engine.lambda$new$0(GraphvizV8Engine.java:31)
        at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.engine(AbstractJsGraphvizEngine.java:65)
        at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.doInit(AbstractJsGraphvizEngine.java:49)
        at guru.nidi.graphviz.engine.AbstractGraphvizEngine.initTask(AbstractGraphvizEngine.java:50)
        at guru.nidi.graphviz.engine.AbstractGraphvizEngine.init(AbstractGraphvizEngine.java:42)
        at guru.nidi.graphviz.engine.Graphviz.doUseEngine(Graphviz.java:146)
        at guru.nidi.graphviz.engine.Graphviz.useEngine(Graphviz.java:138)
        at guru.nidi.graphviz.engine.Graphviz.useEngine(Graphviz.java:119)
        at it.zero11.zanocco.util.MeterMapGenerator.<clinit>(MeterMapGenerator.java:34)
        at it.zero11.zanocco.ui.views.plants.PlantMetersTab.setPlant(PlantMetersTab.java:84)
        at it.zero11.zanocco.ui.views.plants.PlantEditView.setParameter(PlantEditView.java:120)
        at it.zero11.zanocco.ui.views.plants.PlantEditView.setParameter(PlantEditView.java:31)
        at com.vaadin.flow.router.internal.NavigationStateRenderer.notifyNavigationTarget(NavigationStateRenderer.java:88)
        at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.handle(AbstractNavigationStateRenderer.java:181)
        at com.vaadin.flow.router.Router.handleNavigation(Router.java:228)
        at com.vaadin.flow.router.Router.navigate(Router.java:199)
        at com.vaadin.flow.component.UI.navigate(UI.java:791)
        at com.vaadin.flow.component.UI.navigate(UI.java:754)
        at com.vaadin.flow.component.UI.navigate(UI.java:737)
        at it.zero11.zanocco.ui.views.plants.PlantView.lambda$createEditButton$5ed070bc$1(PlantView.java:121)
        at com.vaadin.flow.component.ComponentEventBus.fireEvent(ComponentEventBus.java:133)
        at com.vaadin.flow.component.ComponentEventBus.handleDomEvent(ComponentEventBus.java:327)
        at com.vaadin.flow.component.ComponentEventBus.lambda$addDomTrigger$5ee67f2b$1(ComponentEventBus.java:191)
        at com.vaadin.flow.internal.nodefeature.ElementListenerMap.lambda$fireEvent$2(ElementListenerMap.java:379)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
        at com.vaadin.flow.internal.nodefeature.ElementListenerMap.fireEvent(ElementListenerMap.java:379)
        at com.vaadin.flow.server.communication.rpc.EventRpcHandler.handleNode(EventRpcHandler.java:59)
        at com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:64)
        at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:377)
        at com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$0(ServerRpcHandler.java:367)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
        at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:367)
        at com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:309)
        at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:89)
        at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
        at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1500)
        at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:302)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: Could not load J2V8 library. Reasons: 
        no j2v8_linux_x86_64 in java.library.path

        at com.eclipsesource.v8.LibraryLoader.loadLibrary(LibraryLoader.java:75)
        at com.eclipsesource.v8.V8.load(V8.java:71)
        at com.eclipsesource.v8.V8.createV8Runtime(V8.java:145)
        ... 61 more

On windows all works fine and the log say:

[http-nio-8080-exec-4] INFO guru.nidi.graphviz.engine.V8JavascriptEngine - Starting V8 runtime...
[http-nio-8080-exec-4] INFO guru.nidi.graphviz.engine.V8JavascriptEngine - Started V8 runtime. Initializing javascript...
[http-nio-8080-exec-4] INFO guru.nidi.graphviz.engine.V8JavascriptEngine - Initialized javascript.

On eclipse I can see the Maven Dependencies:

image

Any tips on how to make it work on linux?

aetasoul commented 2 years ago

After some test I can see that if I run the application on the Ubuntu machine where I compile it all works good, when I copy the war to the production server it is missing the linux package..

Seems that compiling the linux part is lost, if I run the application on the linux machine where I compile it all works good, after copying the war on the production server is broken.

aetasoul commented 2 years ago

The problem is that the file .so is not copied to the user directory. I'm running the application on tomcat8 deployed as .war file. When unpacked the file is not copied to tomcat8 home directory.

Fixed using dot command installing grphviz