asciidoctor / asciidoctorj-pdf

AsciidoctorJ PDF bundles the Asciidoctor PDF RubyGem (asciidoctor-pdf) so it can be loaded into the JVM using JRuby.
Apache License 2.0
35 stars 17 forks source link

Run in OSGi #94

Open akera-io opened 1 year ago

akera-io commented 1 year ago

Hi guys, trying to upgrade to latest versions since 1.6.x is quite old already and not going to be maintained anymore. The problem we have is that we use this in an OSGi environment, we're loading all the 'gems' from asciidoctor and asciidoctor-pdf jars by passing the list to the Factory create method. This was/is working fine in 1.6.x version, it stops working since 2.0.x (as I've tried to go down backward trying to find a combination that could work)., the error originates from theme_loader.rb: org.jruby.exceptions.SystemCallError: (ENOTDIR) Not a directory - uri:classloader:/gems/asciidoctor-pdf-2.3.7/data/themes at org.jruby.RubyDir.initialize(org/jruby/RubyDir.java:146) at org.jruby.RubyClass.new(org/jruby/RubyClass.java:917) at org.jruby.RubyDir.children(org/jruby/RubyDir.java:488) at org.jruby.RubyDir.children(org/jruby/RubyDir.java:483) at RUBY.<class:ThemeLoader>(uri:classloader:/gems/asciidoctor-pdf-2.3.7/lib/asciidoctor/pdf/theme_loader.rb:16) at RUBY.<module:PDF>(uri:classloader:/gems/asciidoctor-pdf-2.3.7/lib/asciidoctor/pdf/theme_loader.rb:8) at RUBY.<module:Asciidoctor>(uri:classloader:/gems/asciidoctor-pdf-2.3.7/lib/asciidoctor/pdf/theme_loader.rb:7) at RUBY.<main>(uri:classloader:/gems/asciidoctor-pdf-2.3.7/lib/asciidoctor/pdf/theme_loader.rb:6) at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1057) at org.jruby.RubyKernel.require_relative(org/jruby/RubyKernel.java:1084) at RUBY.<main>(uri:classloader:/gems/asciidoctor-pdf-2.3.7/lib/asciidoctor/pdf.rb:15) at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1057) at org.jruby.RubyKernel.require_relative(org/jruby/RubyKernel.java:1084) at RUBY.<main>(uri:classloader:/gems/asciidoctor-pdf-2.3.7/lib/asciidoctor-pdf.rb:3)

Trying to debug this one when the script tries to load the themes the themes folder resolves to uri:classloader:/gems/asciidoctor-pdf-2.3.7/data/themes which looks fine imho. However this doesn't load anything under it so it looks like is not a folder, hence the exception :(

The difference being in 2.x version the theme loaded tries to get all bundled themes (BundledThemeNames = (::Dir.children ThemesDir).map {|it| it.slice 0, it.length - 10 }), and this fails - maybe a .jrubydir flag-file could solve this issue? The listClassLoaderFiles method in URIResource does look for it. Otherwise the bundle class loader can't resolve gems/asciidoctor-pdf-2.3.7/data/themes. Anything that we might need to change to make it work, is this still possible to run in an OSGi environment?

Thanks