{"record":{"id":"f5fa95d53b7d1681","repo":"jruby/jruby","slug":"osgi-libraries-are-only-supported-with-a-jrubyosgi","errorCode":null,"errorMessage":"osgi libraries are only supported with a JRubyOSGiBundleClassLoader as the  loader of the ScriptingContainer.","messagePattern":"osgi libraries are only supported with a JRubyOSGiBundleClassLoader as the  loader of the ScriptingContainer\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/jruby/embed/osgi/internal/OSGiBundleLibrary.java","lineNumber":61,"sourceCode":"    \n    private final Bundle bundle;\n\n    public OSGiBundleLibrary(Bundle bundle) {\n        this.bundle = bundle;\n    }\n\n    public void load(Ruby runtime, boolean wrap) {\n        // Make Java class files in the bundle and resources reachable from Ruby\n\n        //don't remove this and in-line it: we need this bundle to explicitly\n        //import the package org.jruby.util otherwise we get some weird\n        //classnotfound exception 'org.jruby.util.JRubyClassLoader'\n        JRubyClassLoader jrubycl = (JRubyClassLoader)runtime.getJRubyClassLoader();\n        ClassLoader cl = jrubycl.getParent();\n        if (cl instanceof JRubyOSGiBundleClassLoader) {\n            ((JRubyOSGiBundleClassLoader)cl).addBundle(this.bundle);\n        } else {\n            throw new IllegalArgumentException(\"osgi libraries are only\" +\n            \t\t\" supported with a JRubyOSGiBundleClassLoader as the \" +\n            \t\t\" loader of the ScriptingContainer.\");\n        }\n    }\n\n\n}\n","sourceCodeStart":43,"sourceCodeEnd":69,"githubUrl":"https://github.com/jruby/jruby/blob/fb650c13e02b5a600fa66384655069d5ec30c362/core/src/main/java/org/jruby/embed/osgi/internal/OSGiBundleLibrary.java#L43-L69","documentation":"Error \"osgi libraries are only supported with a JRubyOSGiBundleClassLoader as the  loader of the ScriptingContainer.\" thrown in jruby/jruby.","triggerScenarios":"Thrown at core/src/main/java/org/jruby/embed/osgi/internal/OSGiBundleLibrary.java:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["OSGi library loading requires the ScriptingContainer to use a JRubyOSGiBundleClassLoader. Set the container's class loader to a JRubyOSGiBundleClassLoader before adding OSGi bundle libraries."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb650c13e02b5a600fa66384655069d5ec30c362","analyzedAt":"2026-08-23T07:18:57.479Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}