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
36 stars 17 forks source link

When using JRuby 9.x SnakeYaml needs to be on the classpath. #16

Closed ysb33r closed 5 years ago

ysb33r commented 6 years ago

I had some "strange" strange failures with 1.6.0-alpha.11 and JRuby 9.0.5.0.

Typical failure was

aused by: java.lang.NoSuchMethodError: org.yaml.snakeyaml.events.DocumentStartEvent.getVersion()Lorg/yaml/snakeyaml/DumperOptions$Version;
    at org.jruby.ext.psych.PsychParser.handleDocumentStart(PsychParser.java:243)
    at org.jruby.ext.psych.PsychParser.parse(PsychParser.java:192)
    at org.jruby.ext.psych.PsychParser$INVOKER$i$parse.call(PsychParser$INVOKER$i$parse.gen)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrTwo.call(JavaMethod.java:1081)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:729)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:273)
    at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:79)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:

The problem is resolved when SnakeYaml v1.13 is placed on the classpath.

I am not really sure how this should be resolved at a build level atm, but it is worthwhile raising as an issue so that it can be considred for testing purposes.

mouyang commented 5 years ago

I think the issue is with JRuby and not with Asciidoctor. I haven't downloaded JRuby 9.0.5.0 but jruby-complete-9.1.8.0.jar includes a SnakeYAML jar which is being ignored by JRuby. Putting SnakeYAML 1.19 in my classpath worked until I tried to upgrade a Spring Boot 2.0.2.RELEASE project to 2.1.2.RELEASE which uses SnakeYAML 1.23. At that point, I received a strange error myself:

uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.

For what it's worth, I upgrade my dependencies to asciidoctorj 1.6.0 and asciidoctorj-pdf 1.5.0-alpha.16 which use SnakeYAML 1.23 and received a different error, but I don't think that issue is in the scope of this ticket. Even if I received no errors, I had to do the same workaround as you did.

@ysb33r While adding SnakeYAML to the classpath worked for you and I as described previously, I don't think this is something developers should have to do. JRuby should use the jar that is contained in the jruby-complete-x.jar. I think the correct resolution is to file a ticket against JRuby. What do you think?

ysb33r commented 5 years ago

@mouyang The real issue was Gradle polluting the classpath with its own internal version of snakeyaml