jruby/jruby · error · IllegalArgumentException

osgi libraries are only supported with a JRubyOSGiBundleClas

Error message

osgi libraries are only supported with a JRubyOSGiBundleClassLoader as the  loader of the ScriptingContainer.

What it means

Error "osgi libraries are only supported with a JRubyOSGiBundleClassLoader as the loader of the ScriptingContainer." thrown in jruby/jruby.

Source

Thrown at core/src/main/java/org/jruby/embed/osgi/internal/OSGiBundleLibrary.java:61

    
    private final Bundle bundle;

    public OSGiBundleLibrary(Bundle bundle) {
        this.bundle = bundle;
    }

    public void load(Ruby runtime, boolean wrap) {
        // Make Java class files in the bundle and resources reachable from Ruby

        //don't remove this and in-line it: we need this bundle to explicitly
        //import the package org.jruby.util otherwise we get some weird
        //classnotfound exception 'org.jruby.util.JRubyClassLoader'
        JRubyClassLoader jrubycl = (JRubyClassLoader)runtime.getJRubyClassLoader();
        ClassLoader cl = jrubycl.getParent();
        if (cl instanceof JRubyOSGiBundleClassLoader) {
            ((JRubyOSGiBundleClassLoader)cl).addBundle(this.bundle);
        } else {
            throw new IllegalArgumentException("osgi libraries are only" +
            		" supported with a JRubyOSGiBundleClassLoader as the " +
            		" loader of the ScriptingContainer.");
        }
    }


}

View on GitHub (pinned to fb650c13e0)

Solutions

  1. OSGi library loading requires the ScriptingContainer to use a JRubyOSGiBundleClassLoader. Set the container's class loader to a JRubyOSGiBundleClassLoader before adding OSGi bundle libraries.

When it happens

Trigger: Thrown at core/src/main/java/org/jruby/embed/osgi/internal/OSGiBundleLibrary.java:61 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jruby/jruby@fb650c13e0 (2026-08-23). Data as JSON: /api/errors/f5fa95d53b7d1681. Report an issue: GitHub.