asciidoctor / asciidoctorj

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

Use of 1.6.0-alpha.6 in WildFly #639

Open oliviercailloux opened 6 years ago

oliviercailloux commented 6 years ago

The doc in README indicates that in an OSGi environment, the Factory create method accepting a class loader has to be used. But it is deprecated in 1.6.0-alpha.6.

Also, the README gives instructions about adding asciidoctor as a module to WildFly, but does not explain why this is useful (or necessary?).

Indeed I managed to make it load by adding it as a module and using Asciidoctor.Factory.create(Arrays.asList("META-INF/jruby.home/lib/ruby"), "gems/asciidoctor-1.5.6.1/lib"). (I tried to find the right paths to use by looking in the jruby-complete-9.1.12.0.jar and asciidoctorj-1.6.0-alpha.6.jar. But I don’t really understand what I’m doing…)

I would much prefer to get rid of the Wildfly module as it makes deployment more complex. Is this module really necessary? (Indeed I could not create an asciidoc instance before following the instructions about the module, but it is highly likely that I overlooked something.) I use other libraries with no problem and no need to include them as modules: the libraries are included in the war.

If it is necessary to do so in Wildfly, can someone tell me briefly why or point to some relevant documentation? It makes me wonder whether the application will work on other Java EE servers. (I tried Glassfish, it works with no special configuration and a simple Factory.create(), but I don’t know about other servers, and besides, I would like to ensure that my application is correct considering the specs, not just see that it works by trial and error.)

I am willing to propose a patch to improve the README once I understand the whole process…

robertpanzer commented 6 years ago

This is due to Wildly implementing an own ClassLoader that enforces many properties. One thing for example is that Crypto providers can only be loaded from a Module, not from a Deployment. (And I think JRuby even fails on this one iirc, because it tries to register an own crypto provider but I might be wrong) For details please check the documentation of Wildfly for details.

It's hard to speak for other application servers, because they all do sth with class loading, but servers like TomEE or WAS shouldn't have these problems.

oliviercailloux commented 6 years ago

The latest WildFly developer guide has a chapter about modules. But it doesn’t say anything related to our point, AFAICS. On the contrary, it indicates that if a resource is not found as a system dependency or in a module, it will be loaded from the local resources. The administrator guide is not helpful either. And searching for “wildfly modules cryptographic providers” or similar queries does not seem to yield recent related doc.

More specifically, my questions are:

If anyone can provide hints or pointers, I’d be most interested.