> > Have I done anything different from you? What OSGi framework are you using? > Is there a particular bundled gem that you're unable to load?
Thanks a lot for checking this out. We're using Equinox as well. We're on an older version though, so I wonder if that has something to do with this (osgi-3.5.2.R35x_v20100126.jar). We have some other issues that prevent us from upgrading for now. I was actually able to get past the gem loading issue by manually setting GEM_PATH to the appropriate path (ugly, but I wanted to see if it would work): scriptingContainer.runScriptlet("ENV['GEM_PATH']='/opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared'"); However, then the code blew up with a NoClassDefFoundError for a Java class that is in my OSGi bundle. In my case it just looks like when using CONCURRENT the JRuby code is not playing nice with OSGi. Here are the relevant log messages showing the ruby load path and Gem path as well the error message. 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] inside bootstrap.rb... 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] $LOAD_PATH: 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared/gems/i18n-0.6.4/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared/gems/multi_json-1.6.1/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared/gems/activesupport-3.2.12/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared/gems/builder-3.0.4/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared/gems/activemodel-3.2.12/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared/gems/cartesian-0.6.7/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] classpath:/META-INF/jruby.home/lib/ruby/1.9/site_ruby 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] classpath:/META-INF/jruby.home/lib/ruby/shared 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] classpath:/META-INF/jruby.home/lib/ruby/1.9 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/dynamic_plugin/lib 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] GEM_PATH: 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] classpath:/META-INF/jruby.home/lib/ruby/gems/shared 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] /opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared ... 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] org.osgi.framework.BundleException: Exception in com.raritan.polaris.plugins.dynamic.Activator.start() of bundle com.raritan.polaris.plugins.dynamic ... 2013/03/28 15:35:16 INFO [/opt/raritan/polaris/init/scripts/polaris.pl(414)] Caused by: java.lang.NoClassDefFoundError: com/raritan/polaris/plugins/dynamic/bridge/IRuntime ------------------------------------------------------------ The IRuntime class is definitely in the bundle being started: [root@192.168.42.48 /opt/raritan/polaris/lib/plugins] # jar -tvf com.raritan.polaris.plugins.dynamic-4.1.0-6-SNAPSHOT.jar |grep IRuntime 224 Thu Mar 28 16:35:38 EDT 2013 com/raritan/polaris/plugins/dynamic/bridge/IRuntime.class The OSGi Activator.start() method for the for the com.raritan.polaris.plugins.dynamic-4.1.0-6-SNAPSHOT.jar bundle looks like: public void start(BundleContext context) throws Exception { // Using OSGiScriptingContainer instead of vanilla ScriptingContainer now that we are // running JRuby as an OSGi bundle. scriptingContainer = new OSGiScriptingContainer(context.getBundle(),LocalContextScope.CONCURRENT, LocalVariableBehavior.TRANSIENT); scriptingContainer.setCompatVersion(CompatVersion.RUBY1_9); // Work-around JRUBY issue JRUBY-6265 scriptingContainer.runScriptlet("$: << '/opt/raritan/polaris/dynamic_plugin/lib';"); // Let's try to manually set hard-coded GEM_PATH scriptingContainer.runScriptlet("ENV['GEM_PATH']='/opt/raritan/polaris/lib/configuration/org.eclipse.osgi/bundles/3/1/.cp/META-INF/jruby.home/lib/ruby/gems/shared'"); this.dynamicPluginManager = new DynamicPluginManager(scriptingContainer); this.dynamicPluginManager.setPluginLoadPath(System.getProperty("dynamic-plugin.plugins-path", Constants.DYNAMIC_PLUGIN_PLUGINS_PATH)); this.dynamicPluginManager.start(); // Initialize SNMP4J snmpSessionManager = new SnmpSessionManager(); snmpSessionManager.activateSnmp(); // Initialize BridgeUtils BridgeUtils.setDynamicPluginManager(this.dynamicPluginManager); BridgeUtils.setSnmpSession(snmpSessionManager.getSnmpSession()); @SuppressWarnings("rawtypes") Hashtable properties = new Hashtable(); context.registerService(CommandProvider.class.getName(), this, properties); } Not sure what I'm doing wrong. I tried to create a simple jUnit test that reproduces this issue but so far no luck.