Hi everyone,

As you might have guessed, we are in the midst of a ruote-rest+JRuby
testing frenzy. This issue has to do with the way "ruote-rest/lib/
database.yaml" is parsed, given that you use a JDBC driver, instead of
the convenience "adapter: jdbcXXX". For instance:

development:
  adapter: jdbc
  driver: com.mysql.jdbc.Driver
  url: jdbc:mysql://localhost/ruoterest_development
  username: rueda
  password: secret

Now, you'd add "mysql-connector-java-5.0.8-bin.jar" to your CLASSPATH,
or maybe do a:

if RUBY_PLATFORM =~ /java/
    require "#{RUOTE_BASE_DIR}/lib/jars/mysql-connector-java-5.0.8-
bin.jar"
 end

before racking up ruote-rest.
(Note that I'm using MySQL for the test. Any other non-mysql driver
could do as well)

Under these circumstances JRuby would use the more generic
"activerecord-jdbc-adapter" [1]

Well, then let's fire the freshly git-cloned app: jruby --server lib/
start.rb

Now, open a browser and proceed to the web frontend: an exception!

TypeError at /
can't convert nil into String
Ruby    /opt/jruby/jruby-1.3.1_x64/lib/ruby/gems/1.8/gems/activerecord-
jdbc-adapter-0.9.1/lib/active_record/connection_adapters/
jdbc_adapter.rb: in driver_class, line 240

After some raising and pprinting, I got the config params
"activerecord-jdbc-adapter" gets from ruote-rest:

#<ActiveRecord::Base::ConnectionSpecification:0x6cc
 @adapter_method="jdbc_connection",
 @config=
  {:adapter=>"jdbc",
   :database=>nil,
   :username=>"root",
   :password=>"2secure",
   :host=>nil,
   :encoding=>nil,
   :pool=>30}>

To my surprise, "adapter" and "driver" are missing. Which led me to
"ruote-rest/lib/ar_conn.rb":

 41     ActiveRecord::Base.establish_connection(
 42       :adapter => configuration['adapter'],
 43       :database => configuration['database'],
 44       :username => configuration['username'],
 45       :password => configuration['password'],
 46       :host => configuration['host'],
 47       :encoding => configuration['encoding'],
 48       :pool => 30
 49     )

It seems that only the parameters above reach activerecord. That's OK
for Ruby, but for JRuby + "activerecord-jdbc-adapter" to work, it
would be necessary to add these:

:driver => configuration['driver'],
:url => configuration['url'],

And, if you want to warble the app, thus using it on an application
server (then skip what I wrote about the CLASSPATH and the jar):

:jndi => configuration['jndi']

***
Having those extra lines added to "lib/ar_conn.rb" would help a lot to
those who wanted to take ruote-rest for a spin on JRuby. Besides, they
are quite harmless to Ruby's "activerecord".

Best regards. Have a nice weekend!
//nando

-------
[1] http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter/
--~--~---------~--~----~------------~-------~--~----~
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to