asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
445 stars 109 forks source link

Getting NoClassDefFoundError for GraphvizUtils after upgrading asciidoctor-diagram-plantuml #426

Closed ShayArtzi closed 1 year ago

ShayArtzi commented 1 year ago

Hi folks,

First of all, thanks very much for all your awesome work - I appreciate it a lot :)

I have noticed an issue after upgrading asciidoctor-diagram version. It's possible I'm missing something but here is what I did:

Environment: OS: win10 Ruby version: 3.2.2 Relevant gems:

asciidoctor (2.0.20)
asciidoctor-diagram (2.2.3)
asciidoctor-diagram-ditaamini (1.0.3)
asciidoctor-diagram-plantuml (1.2022.5)
asciidoctor-pdf (2.3.9)
asciidoctor-plantuml (0.1.1)

When I change the version of asciidoctor-diagram-plantuml from 1.2022.5 to 1.2023.5, plantuml diagrams generation fails with the following error (this works fine with the dependency list mentioned above, meaning when using asciidoctor-diagram-plantuml 1.2022.5):

$ asciidoctor.bat -r asciidoctor-diagram c:/dev/temp/text/src/root.adoc -o c:/dev/temp/text/target/index.html
Exception in thread "main" java.util.ServiceConfigurationError: org.asciidoctor.diagram.DiagramGenerator: Provider org.asciidoctor.diagram.plantuml.PlantUML could not be instantiated
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
        at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
        at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
        at org.asciidoctor.diagram.AbstractCommandServer.loadGenerators(AbstractCommandServer.java:31)
        at org.asciidoctor.diagram.AbstractCommandServer.<clinit>(AbstractCommandServer.java:14)
Caused by: java.lang.NoClassDefFoundError: net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils
        at org.asciidoctor.diagram.plantuml.PlantUML.<clinit>(PlantUML.java:37)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
        ... 4 more
Caused by: java.lang.ClassNotFoundException: net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 11 more
asciidoctor: ERROR: chapter-02.adoc: line 71: Failed to generate image: Error processing request {:url=>"/plantumlpreprocessor", :body=>"@startuml\nskinparam Legend {\n\tBackgroundColor transparent\n\tBorderColor transparent\n}\nlegend\nMaven Application Directory\n|_ src\n  |_ **main**\n    |_ java/\n    |_ resources/\n  |_ **test**\n    |_ java/\n    |_ resources/\n|_ target\nend legend\n@enduml", :headers=>{"X-PlantUML-Basedir"=>"c:\\dev\\temp\\text\\src"}}
Encoding of input is UTF-8
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/asciidoctor-diagram-2.2.3/lib/asciidoctor-diagram/util/java_socket.rb:34:in `kill': No such process (Errno::ESRCH)
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/asciidoctor-diagram-2.2.3/lib/asciidoctor-diagram/util/java_socket.rb:34:in `shutdown'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/asciidoctor-diagram-2.2.3/lib/asciidoctor-diagram/util/java_socket.rb:53:in `block in instance'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.20/bin/asciidoctor:16:in `exit': exit (SystemExit)
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.20/bin/asciidoctor:16:in `<top (required)>'
        from C:/Ruby32-x64/bin/asciidoctor:32:in `load'
        from C:/Ruby32-x64/bin/asciidoctor:32:in `<main>'

Does this ring any bells? I can also try to create a minimal example if necessary. Thanks very much!

pepijnve commented 1 year ago

PlantUML 1.2023.x incompatibility was fixed in https://github.com/asciidoctor/asciidoctor-diagram/releases/tag/v2.2.6 Could you try updating the asciidoctor-diagram gem to a more recent version?

ShayArtzi commented 1 year ago

Thanks for your reply and support @pepijnve!

Indeed I can confirm the asciidoctor-diagram (2.2.6) and asciidoctor-diagram-plantuml (1.2023.5) works great together on my environment :)

ShayArtzi commented 1 year ago

closing this issue as it is resolved