asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
628 stars 172 forks source link

In version 1.5.4.1 , "(LoadError) no such file to load -- asciidoctor" #540

Closed ajainy closed 7 years ago

ajainy commented 7 years ago

When I upgraded my maven dependencies from v1.5.4 to 1.5.4.1 , i started getting this error "(LoadError) no such file to load -- asciidoctor".

I am not sure, whether I did something wrong. But when I rolled back to prev version, my code started working fine. org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- asciidoctor at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1040) at RUBY.require(/C:/jframeworks/projects/snapcx/src/main/webapp/WEB-INF/lib/jruby-complete-1.7.25.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54) at RUBY.(root)(<script>:9)

abelsromero commented 7 years ago

Hi, Can you provide more information of your case. From the stacktrace it seems to me the app is deployed inside a web application. If so, which server and framework are you using?

ajainy commented 7 years ago

Hi, I am running in tomcat as webapp. This error comes from JSP. Purpose of JSP is, if invoked, it will parse whole directory structure to generate HTML5 document.

Here is JSP code ` <%@ page import="javax.servlet.http." %> <%@ page import="java.util., java.io.File" %> <%@ page import="org.asciidoctor.Asciidoctor" %> <%@ page import="org.asciidoctor.Asciidoctor." %> <%@ page import="org.asciidoctor.AsciiDocDirectoryWalker" %> <%@ page import="org.asciidoctor.OptionsBuilder" %> <%@ page import="org.asciidoctor.OptionsBuilder." %> <%@ page import="org.asciidoctor.*" %>

<%!

final Asciidoctor asciidoctor = Asciidoctor.Factory.create(); final OptionsBuilder bldr = OptionsBuilder.options().safe(SafeMode.SAFE).inPlace(true); //final String inputPath = application.getResource("/docs").getPath(); %> <% String key = request.getParameter("key");

if (null != key && key.equalsIgnoreCase(parseKey)) { //final Asciidoctor asciidoctor = Asciidoctor.Factory.create(); //OptionsBuilder bldr = OptionsBuilder.options().safe(SafeMode.SAFE).inPlace(true); String inputPath = application.getResource("/docs").getPath(); //bldr.inPlace(true); asciidoctor.convertDirectory(new AsciiDocDirectoryWalker(inputPath), bldr.asMap()); } else { response.setStatus(404); } %> `

Ignore logic of checking "key" param. It is to avoid, anyone to invoke this JSP.

abelsromero commented 7 years ago

I am sorry, but I haven't been able to reproduce. Can you provide a full example in a repo? Truth it's been years since I did JSP, but I could create an example based on:

Then adapted your JSP and also implemented conversion directly in a Java Controller and in both cases it worked.

ajainy commented 7 years ago

I am sure, something wrong in my env. My webapp is vanilla JSP webapp. No spring. It's tomcat 8, jre 1.8 and JSTL 1.2 etc.

abelsromero commented 7 years ago

Thanks for the info. I could finally reproduce the issue but in my case the problem is Tomcat 8, and has a simple fix. Luckily if you are using Java 8, you can switch to a newer version of jRuby. I tried with the latest version and everything worked fine, just add this dependency to your pom to override the default version used by AsciidoctorJ.

    <dependency>
      <groupId>org.jruby</groupId>
      <artifactId>jruby-complete</artifactId>
      <version>9.1.6.0</version>
    </dependency>
ajainy commented 7 years ago

Thanks for confirming, I will try it out. I am assuming, this will be still valid defect for this project? so that it can be fixed as part of next minor release.?

abelsromero commented 7 years ago

I am assuming, this will be still valid defect for this project? so that it can be fixed as part of next minor release.?

This is not properly an AsciidoctorJ issue, but I admit is kind-of grey area. Is a known issue that some envrionments with custom Classloaders cause issues with jRuby. That makes that locating the gems embbeded in the jars as well as some extensions or converters sometimes fail. Each case is special and most of the cases the solution revolves around choosing the right jRuby version, or take care of how the app is packaged. Keep in mind that the use of jRuby 1.7.x versions is to keep compatibility with Java 6 for AsciidoctorJ 1.5.x. AsciidoctorJ 1.6.0 will use jRuby 9k by default at the cost of not supporting Java 6, so many scenarios will be fixed. We try our best to provide support and alternatives every time someone rises an issue, but is not something we can fix from our side.

In fact, the ability to customize the jRuby dependency is something we support and in some cases encourage. To mention some cases: · Maven plugin allows to change the jruby version and in the examples repo you'll see different versions depending on the case https://github.com/asciidoctor/asciidoctor-maven-examples · The Asciidoctor Gradle plugin also offer ways to do it, even if not so explicitly. · SpringBoot gradle plugin also acknowledges the special needs of AsciidoctorJ and jRuby packaging and adds the requiresUnpack option to keep those jars from the rest of dependencies. · AsciidoctorJ defines specific instructions to deploy in WildFly https://github.com/asciidoctor/asciidoctorj#installation ...and so others...

I don't have permissions on this repo so, this issue will remain open unless you close it. But I don't think any action will be derived from it.

mojavelinux commented 7 years ago

We'll call this a support case. I'll close it since it provides information about how to address the problem. If someone has an idea for a code change, feel free to propose it.