Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched from java 11 to 17 and now get `initialize': wrong number of arguments (given 1, expected 0) #1285

Open
zenbones opened this issue Sep 20, 2024 · 8 comments

Comments

@zenbones
Copy link

The import is...

      <dependency>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctorj</artifactId>
        <version>3.0.0</version>
      </dependency>

...but I see the same 2.5.7.

The code is...

    try (Asciidoctor asciidoctor = Asciidoctor.Factory.create()) {

      return asciidoctor.convert(<string to convert>, Options.builder().build());
    }

...and I now get...

Caused by: org.smallmind.web.json.scaffold.fault.NativeObjectException: Exception in thread org.jruby.exceptions.ArgumentError: (ArgumentError) asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - `initialize': wrong number of arguments (given 1, expected 0)
   at RUBY.load(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/load.rb:104)
   at RUBY.convert(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/convert.rb:78)
Caused by: org.jruby.exceptions.ArgumentError: (ArgumentError) `initialize': wrong number of arguments (given 1, expected 0)
   at org.jruby.RubyClass.new(org/jruby/RubyClass.java:922)
   at RUBY.initialize(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/attribute_list.rb:54)
   at org.jruby.RubyClass.new(org/jruby/RubyClass.java:935)
   at RUBY.parse_attributes(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/substitutors.rb:1337)
   at uri_3a_classloader_3a_.gems.asciidoctor_minus_2_dot_0_dot_23.lib.asciidoctor.parser.parse_block_metadata_line(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:2059)
   at uri_3a_classloader_3a_.gems.asciidoctor_minus_2_dot_0_dot_23.lib.asciidoctor.parser.parse_block_metadata_lines(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:2015)
   at uri_3a_classloader_3a_.gems.asciidoctor_minus_2_dot_0_dot_23.lib.asciidoctor.parser.next_section(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:373)
   at uri_3a_classloader_3a_.gems.asciidoctor_minus_2_dot_0_dot_23.lib.asciidoctor.parser.next_section(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:388)
   at RUBY.next_section(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:388)
   at RUBY.parse(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:103)
   at RUBY.parse(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/document.rb:538)
   at RUBY.load(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/load.rb:84)
   ... 1 more
@zenbones
Copy link
Author

zenbones commented Sep 20, 2024

I get this error in ubuntu 22.04, openjdk 17, but not in windows with graalvm 17, if that helps...

@abelsromero
Copy link
Member

...but I see the same 2.5.7.

Can you clarify this comment? mvn dependency:tree should show if there's some other version in runtime...even though I thought Maven would pull the latest is set in the pom.

btw, AsciidoctorJ 3.0.0 uses asciidoctor v2.0.23, at least we know that version is in the classpath

@zenbones
Copy link
Author

What I mean is that I get that error under openjdk17 on ubuntu 22.04 with only 2.5.7 on the classpath, or only 3.0.0 on the classpath, but not both at the same time. I can guarantee the classpath because all of our jars are pulled and collected into a lib directory that serves as the classpath for tanukisoft scripts that are hosting the jvm, and all versions are fully sepcified in maven poms, and I have checked both the jars available to my local IDE (intelij), and the jars packed into the tanukisoft distribution, and they are both clean, either 2.5.7 or 3.0.0.

Here's the relevant bit from the lib directory...

apiguardian-api-1.1.2.jar
artifact-maven-6.0.0-SNAPSHOT.jar
asciidoctorj-3.0.0.jar
asciidoctorj-api-3.0.0.jar
asm-9.7.jar
asm-analysis-9.7.jar

..and the only asciidoctor jars are both 3.0.0. I would obviously prefer to resolve this issue with 3.0.0.

What I'm really asking is what the mechanism is that would cause that error. My ability to debug easily ends with...

org.jruby.RubyClass.new(org/jruby/RubyClass.java:922

...and the code there is a dynamic reference into some ruby code, I think... I have no clue how to go further. Is there a file in the asciidoctor jars I can double check? A line of code that should have some signature? Or some piece of java being loaded as a service?

@zenbones
Copy link
Author

I also checked the maven repository on the tanukisoft-based install where I get the error, and it's empty except for a few of our jars containing classpath available text templates. Nothing else in it, so the only asciidocj code on the machine is the 3.0.0 jars listed above. Just as proof maven isn't downloading other versions somehow and confusing the classpath.

@rpanzer-aviatrix
Copy link

It would be great if you could provide a reproducer.
It might make sense checking what JRuby jars are used.

@zenbones
Copy link
Author

zenbones commented Oct 10, 2024

I'd like to hand you a reproducer, but I develop on windows, where I can't get a reproduction. Everything works fine. In ubuntu 24.04 I can reproduce in 2.5.7 0r 3.0.0. If I change the asciidoctorj version in my maven pom to 2.5.2 then the problem goes away in linux as well. With 3.0.0 it pulls jruby 9.4.8.0, which is not surprising as that's the listed dependency. With 2.5.2 it's jruby 9.2.17.0.

I'll try to put together a reproducer in linux and see. The document we feed to asciidoctorj is dynamically constructed, so i's a bit difficult, but I'll see what I can do, maybe capture it and create something small and runnable.

@zenbones
Copy link
Author

Been a while, sorry. I tried to put together a reproducer and was unsuccessful. The project works in ubuntu, with version 3.0.0, but not in our production setup. Production is run under the Tanukisoft wrapper, so I have to guess it may be the culprit. I'll attempt a reproducer. Even if I can reproduce I know that makes it not so much your problem, but if I can get a reproducer, maybe you could help me understand why it fails.

@zenbones
Copy link
Author

zenbones commented Nov 15, 2024

I can not get a reproducer that fails. If I reduce the Tanukisoft wrapper, Grizzly http daemon, Jersey endpoint, plus the several aspectj byte code injected joinpoints which make up our production applicaton, the actual AsciiDoctorJ conversion works perfectly. But with all the production paraphernalia in place, I get...

org.jruby.exceptions.ArgumentError: (ArgumentError) asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - initialize: wrong number of arguments (given 1, expected 0)

And if I drop a breakpoint in JRubyAsciiDoctor,java:256 and poke around in the exception, I find this backtrace for that error...

RUBY.load(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/load.rb:104)

((RubyArgumentError)e.getException().getCause()).backtrace.backtraceObject
0: org/jruby/RubyClass.java:922:in `new'
1: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/attribute_list.rb:54:in `initialize'
2: org/jruby/RubyClass.java:935:in `new'
3: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/substitutors.rb:1337:in `parse_attributes'
4: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:2059:in `parse_block_metadata_line'
5: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:2015:in `parse_block_metadata_lines'
6: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:373:in `next_section'
7: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:388:in `next_section'
8: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:388:in `next_section'
9: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/parser.rb:103:in `parse'
10: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/document.rb:538:in `parse'
11: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/load.rb:84:in `load'
12: uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/convert.rb:78:in `convert'

Any notions? Some way I can capture any more specifics? This errors does not occur with asciidoctorj version 2.5.2 and does with 3.0.0,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants