Skip to content

multiple applications in tomcat and jruby 9.4.3.0 com.headius.invokebinder.InvalidTransformException: java.lang.IllegalAccessException #7911

@jlahtinen

Description

@jlahtinen

Starting multiple rails applications with jruby 9.4.3.0 eventually fails with error

java.lang.NoClassDefFoundError: Could not initialize class org.jruby.ir.targets.indy.Bootstrap
        at org.jruby.ir.targets.indy.ConstantLookupSite.searchConst(ConstantLookupSite.java:107)

After moving all static field initialization (that is the reason line numbers in Bootstrap.java in next strace do not match with tag 9.4.3.0) to one static block and rescuing exception there and loggin it:

com.headius.invokebinder.InvalidTransformException: java.lang.IllegalAccessException: no such field: org.jruby.runtime.ThreadContext.runtime/org.jruby.Ruby/getField
  at com.headius.invokebinder.Binder.getFieldQuiet(Binder.java:1757)
  at org.jruby.ir.targets.indy.Bootstrap.<clinit>(Bootstrap.java:215)
  at org.jruby.ir.targets.indy.IndyValueCompiler.pushNil(IndyValueCompiler.java:133)
  at org.jruby.ir.targets.simple.NormalLocalVariableCompiler.getHeapLocalOrNil(NormalLocalVariableCompiler.java:42)
  at org.jruby.ir.targets.JVMVisitor.LocalVariable(JVMVisitor.java:2751)
  at org.jruby.ir.targets.JVMVisitor.ClosureLocalVariable(JVMVisitor.java:2656)
  at org.jruby.ir.operands.ClosureLocalVariable.visit(ClosureLocalVariable.java:49)
  at org.jruby.ir.targets.JVMVisitor.visit(JVMVisitor.java:636)
  at org.jruby.ir.targets.JVMVisitor.compileCallCommon(JVMVisitor.java:1235)
  at org.jruby.ir.targets.JVMVisitor.CallInstr(JVMVisitor.java:1225)
  at org.jruby.ir.instructions.CallInstr.visit(CallInstr.java:150)
  at org.jruby.ir.targets.JVMVisitor.visit(JVMVisitor.java:632)
  at org.jruby.ir.targets.JVMVisitor.emitScope(JVMVisitor.java:305)
  at org.jruby.ir.targets.JVMVisitor.emitClosure(JVMVisitor.java:600)
  at org.jruby.ir.targets.JVMVisitor.emitClosures(JVMVisitor.java:592)
  at org.jruby.ir.targets.JVMVisitor.emitScope(JVMVisitor.java:212)
  at org.jruby.ir.targets.JVMVisitor.emitWithSignatures(JVMVisitor.java:554)
  at org.jruby.ir.targets.JVMVisitor.emitMethodJIT(JVMVisitor.java:518)
  at org.jruby.ir.targets.JVMVisitor.codegenScope(JVMVisitor.java:186)
  at org.jruby.ir.targets.JVMVisitor.compileToBytecode(JVMVisitor.java:139)
  at org.jruby.compiler.MethodJITClassGenerator.compile(MethodJITClassGenerator.java:59)
  at org.jruby.compiler.MethodJITTask.exec(MethodJITTask.java:76)
  at org.jruby.compiler.JITCompiler$Task.run(JITCompiler.java:301)
  at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
  at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalAccessException: no such field: org.jruby.runtime.ThreadContext.runtime/org.jruby.Ruby/getField
  at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:959)
  at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1101)
  at java.base/java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:2021)
  at java.base/java.lang.invoke.MethodHandles$Lookup.findGetter(MethodHandles.java:1418)
  at com.headius.invokebinder.Binder.getField(Binder.java:1714)
  at com.headius.invokebinder.Binder.getFieldQuiet(Binder.java:1755)
  ... 27 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving field "runtime" of type org.jruby.Ruby, the class loader 'bootstrap' of the current class, java.lang.Object, and the class loader org.apache.catalina.loader.ParallelWebappClassLoader @31f79d66 for the field's defining type, org.jruby.runtime.ThreadContext, have different Class objects for type org.jruby.Ruby (java.lang.Object is in module java.base of loader 'bootstrap'; org.jruby.runtime.ThreadContext is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @31f79d66, parent loader java.net.URLClassLoader @2b71fc7e)
  at java.base/java.lang.invoke.MethodHandleNatives.resolve(Native Method)
  at java.base/java.lang.invoke.MemberName$Factory.resolve(MemberName.java:1070)
  at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1098)
  ... 31 more

Failing row seems to be

private static final MethodHandle RUNTIME_FROM_CONTEXT_HANDLE =

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions