Redbrige ActiveRecord problem

Hi !

I encountered some problem when try using ActiveRecord from an embedded
ruby script.

I call the script like this:

ScriptingContainer container = new ScriptingContainer();
this.getClass().getResourceAsStream(“test.rb”);
container.runScriptlet(this.getClass().getResourceAsStream(“test.rb”),
“test.rb”);

The first problem was that require ‘rubygems’ didn’t update the include
path. So I modified the include path manually (see script)

But now I get:

/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in
establish_connection': Please install the jdbcmysql adapter:gem
install activerecord-jdbcmysql-adapter` (no such file to load –
active_record/connection_adapters/jdbcmysql_adapter) (RuntimeError)
from test.rb:27

The questions are

1.) Is it neccessry to build the include path manually ?

2.) What must I do to make ActiveRecord work ?

Regards
Roger

This is the script I would like to run:

["/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/vendor/i18n-0.1.3/lib",
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/vendor/tzinfo-0.3.12”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/vendor/memcache-client-1.7.4”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/builder-2.1.2/bin”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/builder-2.1.2/lib”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-2.3.4/bin”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activesupport-2.3.4/bin”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/bin”,
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/lib”,
“/Users/roger/Library/jruby/lib/ruby/site_ruby/1.8”,
“/Users/roger/Library/jruby/lib/ruby/site_ruby/shared”,
“/Users/roger/Library/jruby/lib/ruby/1.8”].each do |entry|
$: << entry
end

puts $:
require ‘java’

didn’t help

require
‘/Users/roger/Library/javalibs/mysql-connector-java-5.0.8-bin.jar’

require ‘active_record’
require ‘jdbc_adapter’
require ‘active_record/connection_adapters/mysql_adapter.rb’

conf =
YAML::load(File.open(’/Users/roger/NetBeansProjects/RedBrigeTest/src/redbrigetest/config.yaml’))
ActiveRecord::Base.establish_connection(conf[“mysql”])


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Roger,

On Sun, Dec 20, 2009 at 7:46 AM, Roger G. [email protected] wrote:

The first problem was that require ‘rubygems’ didn’t update the include path. So I modified the include path manually (see script)

But now I get:

/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in establish_connection': Please install the jdbcmysql adapter:gem install activerecord-jdbcmysql-adapter` (no such file to load – active_record/connection_adapters/jdbcmysql_adapter) (RuntimeError)
from test.rb:27

Probably, you need to set load paths to get activerecord work. JRuby
wiki, http://kenai.com/projects/jruby/pages/RedBridge#Class_Path,
explains how to do that. Would you try this?

FYI:
container.runScriptlet(PathType.CLASSPATH, “test.rb”);
does the same as what you did.

-Yoko

This is the script I would like to run:
“/Users/roger/Library/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/bin”,
require ‘/Users/roger/Library/javalibs/mysql-connector-java-5.0.8-bin.jar’
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Yoko,

thanks for the hint. I tried different things and and it seems that it
is sufficient to set JRuby home. After that require ‘rubygems’ works as
expected.

Regards
Roger