Quantcast

asciidoctorj-pdf: (RuntimeError) can't modify frozen array

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

asciidoctorj-pdf: (RuntimeError) can't modify frozen array

Jeremie Bresson
This post was updated on .
We are using asciidoctor inside maven to produce PDF. Version are similar to what is set in the maven-example repository:

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <asciidoctor.maven.plugin.version>1.5.5</asciidoctor.maven.plugin.version>
        <asciidoctorj.pdf.version>1.5.0-alpha.14</asciidoctorj.pdf.version>
        <asciidoctorj.version>1.5.5</asciidoctorj.version>
        <jruby.version>9.1.8.0</jruby.version>

The stacktrace in maven is (with -X flag):
[ERROR] Failed to execute goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc (asciidoc-to-pdf) on project adoc-bsi-theme: Execution asciidoc-to-pdf of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc failed: (RuntimeError) can't modify frozen array -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc (asciidoc-to-pdf) on project adoc-bsi-theme: Execution asciidoc-to-pdf of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc failed: (RuntimeError) can't modify frozen array
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution asciidoc-to-pdf of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc failed: (RuntimeError) can't modify frozen array
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more
Caused by: org.jruby.exceptions.RaiseException: (RuntimeError) can't modify frozen array
        at org.jruby.RubyArray.<<(org/jruby/RubyArray.java:1241)
        at RUBY.<main>(uri:classloader:/gems/prawn-templates-0.0.3/lib/prawn/templates.rb:246)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:961)
        at RUBY.(root)(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1)
        at RUBY.<main>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:961)
        at RUBY.(root)(uri:classloader:/gems/asciidoctor-pdf-1.5.0.alpha.14/lib/asciidoctor-pdf/converter.rb:10)
        at RUBY.<main>(uri:classloader:/jruby/kernel/kernel.rb:1)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:961)
        at RUBY.require_relative(uri:classloader:/jruby/kernel/kernel.rb:13)
        at RUBY.<main>(uri:classloader:/gems/asciidoctor-pdf-1.5.0.alpha.14/lib/asciidoctor-pdf.rb:3)
[ERROR]

I am not a ruby developer/user, but if I read it correctly, the problem is located in "prawn-templates-0.0.3"

Question 1:
Is there a way to replace the gem contained in the asciidoctorj-pdf-1.5.0-alpha.14.jar (prawn- templates-0.0.3) with a newer version like 0.1.1 (locally in my maven build).
See: https://rubygems.org/gems/prawn-templates
I have tried to use the "RubyGems.org Proxy" in maven. I see the gems in "target/gems-provided/gems", but I have the feeling that they are ignored when asciidoctorj is executed.

Question 2:
Where should I file an issue in GitHub? Is the repository "asciidoctor/asciidoctorj" correct?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

Jeremie Bresson
For question 1:

I found my problem. The configuration in the plugin section "asciidoctor-maven-plugin" was wrong. It needs to be set to:
<gemPath>${project.build.directory}/gems-provided/gems/</gemPath>

I had copied it from the example (line 90):
<gemPath>${project.build.directory}/gems-provided</gemPath>

I guess it is also wrong there.

My build is now working with:
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <asciidoctor.maven.plugin.version>1.5.5</asciidoctor.maven.plugin.version>
    <asciidoctorj.pdf.version>1.5.0-alpha.14</asciidoctorj.pdf.version>
    <asciidoctorj.version>1.5.5</asciidoctorj.version>
    <jruby.version>9.1.8.0</jruby.version>
    <rubygems.prawn.version>2.2.2</rubygems.prawn.version>
    <rubygems.prawntemplates.version>0.1.1</rubygems.prawntemplates.version>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

abelsromero
Not sure about the cause of the issue, but I am quite sure the path should be `<gemPath>${project.build.directory}/gems-provided</gemPath>`, "gems" is the root of the gems repository, it is assumen by the JRuby runtime under-the-hood.

At least I modified the example to directly use the `asciidoctor-pdf` gem without asciidoctorJ-pdf, so it pulls all proper gems and it works only if I set that path without "gems".
If you still need to replace some gem, with the example you can manage all gems as normal Maven dependencies.

https://github.com/abelsromero/asciidoctor-maven-examples/blob/support/pdf_gem_usage/asciidoctor-pdf-with-theme-example/pom.xml#L34-L46


EDIT: I noticed the example setted prawn directly an I recall that was a workarround for some issue. I think we can remove that with the last versions.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

mojavelinux
Administrator
In reply to this post by Jeremie Bresson
It appears you're using AsciidoctorJ PDF 1.5.0.alpha.14 with Prawn 2.2.0. That's not a valid combination, as we discovered in the run up to the release of Asciidoctor PDF 1.5.0.alpha.15.

You either need to use Prawn 2.1.0 or you need to upgrade Asciidoctor PDF to 1.5.0.alpha.15. The problem is actually not with prawn-templates (it was a problem in Prawn core). Asciidoctor PDF isn't yet tested against prawn-templates 0.1.1. It's best to focus on either downgrading to Prawn 2.1.0 or upgrading Asciidoctor PDF.

We're probably going to need an AsciidoctorJ PDF 1.5.0.alpha.15 release soon anyway, which solved 16 issues.

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

mojavelinux
Administrator
In reply to this post by Jeremie Bresson

On Tue, Apr 4, 2017 at 11:40 PM, Jeremie Bresson [via Asciidoctor :: Discussion] <[hidden email]> wrote:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <asciidoctor.maven.plugin.version>1.5.5</asciidoctor.maven.plugin.version>
    <asciidoctorj.pdf.version>1.5.0-alpha.14</asciidoctorj.pdf.version>
    <asciidoctorj.version>1.5.5</asciidoctorj.version>
    <jruby.version>9.1.8.0</jruby.version>
    <rubygems.prawn.version>2.2.2</rubygems.prawn.version>
    <rubygems.prawntemplates.version>0.1.1</rubygems.prawntemplates.version>

It would be better to set prawn-templates to 0.0.5. I haven't yet tested prawn-templates 0.1.1.

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

Jeremie Bresson
In reply to this post by mojavelinux
mojavelinux wrote
We're probably going to need an AsciidoctorJ PDF 1.5.0.alpha.15 release
soon anyway, which solved 16 issues.
From what I can see, there is no 1.5.0-alpha.15 release of  org.asciidoctor:asciidoctorj-pdf in maven central. The last one is 1.5.0-alpha.14. Of course I will update when it is published.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

Jeremie Bresson
In reply to this post by abelsromero
abelsromero wrote
Not sure about the cause of the issue, but I am quite sure the path should be `<gemPath>${project.build.directory}/gems-provided</gemPath>`, "gems" is the root of the gems repository, it is assumen by the JRuby runtime under-the-hood.
I am not sure about that. I have now really an example where the build fails with:
<gemPath>${project.build.directory}/gems-provided</gemPath>
and not with:
<gemPath>${project.build.directory}/gems-provided/gems</gemPath>

My understanding of the stacktrace is that the gems of the jars are used in the first case and not in the second.

abelsromero wrote
At least I modified the example to directly use the `asciidoctor-pdf` gem without asciidoctorJ-pdf, so it pulls all proper gems and it works only if I set that path without "gems".
If you still need to replace some gem, with the example you can manage all gems as normal Maven dependencies.

https://github.com/abelsromero/asciidoctor-maven-examples/blob/support/pdf_gem_usage/asciidoctor-pdf-with-theme-example/pom.xml#L34-L46
I will give your example a try. It is the occasion to use 1.5.0-alpha.15 without having to wait for the asciidoctorj-pdf release mentioned by Dan earlier.

abelsromero wrote
EDIT: I noticed the example setted prawn directly an I recall that was a workarround for some issue. I think we can remove that with the last versions.
This is absolutely correct. The example might be outdated. If I have understood it correctly, 1.5.0-alpha.14 brings a newer version of prawn as the one used in this example.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

abelsromero
I don't see why paths should change and required adding "gems", but it wouldn't be a surprise.
We are running ruby gems through jRuby and the location of elements in the classpath sometimes does weird things.
If you have an example share it for sure!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

Jeremie Bresson
Sorry I was really busy and I had to make a break with the Asciidoctor project in our company.

I have tried to reproduce the exposed problem in a separate project (using the maven example repo as base). I did not manage to do it. I cannot explain/reproduce the problem.

I hope an asciidoctorj-pdf 1.5.0.alpha.15 Version will be published soon on maven central.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

abelsromero
Don't worry  Jeremy, we all have busy lifes. And btw,`asciidoctorj-pdf 1.5.0.alpha.15` is already out,  give it a try and luckily it will solve your problem.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: asciidoctorj-pdf: (RuntimeError) can't modify frozen array

Jeremie Bresson
Thank you, I could revert all my "Ruby Gem Proxy" configuration in the POM file.

It works well !
Loading...