[jruby] Cannot run rake db:migrate with AR-JDBC against Oracle 12c

Ewan Slater ewan.slater at gmail.com
Sun Jul 19 06:21:13 JST 2015


Hi,

I would appreciate any advice getting AR-JDBC running against Oracle 12c.

When I try to run

rake db:migrate

I get the following error:

NoMethodError: undefined method `type' for "VARCHAR2(255)":String

(see below for verbose history of everything).

I have done some Googling, but did not find anything for JRuby / AR-JDBC.

Any pointers to help me resolve this error would be much appreciated.

Cheers,

Ewan

I am using:

Rails 4.2.3

jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on OpenJDK 64-Bit Server
VM 1.7.0_75-b13 +jit [linux-amd64]

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

My database.yml file is as follows:

#
default: &default
  adapter: jdbc
  driver: oracle.jdbc.OracleDriver

development:
  <<: *default
  url: jdbc:oracle:thin:hr/hr@//localhost:1521/PDB1

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  url: jdbc:oracle:thin:hr/hr@//localhost:1521/PDB2

production:
  <<: *default
  url: jdbc:oracle:thin:hr/hr@//localhost:1521/PDB3

Terminal trace:

crush-157: ~/Applications/test_app $ rails generate model Article
title:string text:text
NOTE: ActiveRecord 4.2 is not (yet) fully supported by AR-JDBC, please
help us finish 4.2 support - check http://bit.l
y/jruby-42 for starters
      invoke  active_record
      create    db/migrate/20150718204904_create_articles.rb
      create    app/models/article.rb
      invoke    test_unit
      create      test/models/article_test.rb
      create      test/fixtures/articles.yml
crush-157: ~/Applications/test_app $ ls
Gemfile  Gemfile.lock  README.rdoc  Rakefile  app  bin  config
config.ru  db  lib  log  public  test  tmp  vendor
crush-157: ~/Applications/test_app $ cat
db/migrate/20150718204904_create_articles.rb
class CreateArticles < ActiveRecord::Migration
  def change
    create_table :articles do |t|
      t.string :title
      t.text :text

      t.timestamps null: false
    end
  end
end
crush-157: ~/Applications/test_app $
crush-157: ~/Applications/test_app $ rake db:migrate
NOTE: ActiveRecord 4.2 is not (yet) fully supported by AR-JDBC, please
help us finish 4.2 support - check http://bit.l
y/jruby-42 for starters
rake aborted!
NoMethodError: undefined method `type' for "VARCHAR2(255)":String

Tasks: TOP => db:migrate
(See full trace by running task with --trace)
crush-157: ~/Applications/test_app $ rake --trace db:migrate
NOTE: ActiveRecord 4.2 is not (yet) fully supported by AR-JDBC, please
help us finish 4.2 support - check http://bit.l
y/jruby-42 for starters
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
NoMethodError: undefined method `type' for "VARCHAR2(255)":String
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_meth
ods/time_zone_conversion.rb:64:in `create_time_zone_conversion_attribute?'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_meth
ods/time_zone_conversion.rb:53:in `inherited'
org/jruby/RubyProc.java:271:in `call'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_deco
rators.rb:61:in `matching'
org/jruby/RubyArray.java:2468:in `select'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_deco
rators.rb:60:in `matching'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_deco
rators.rb:56:in `decorators_for'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_deco
rators.rb:47:in `apply'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_deco
rators.rb:29:in `add_user_provided_columns'
org/jruby/RubyArray.java:2412:in `map'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attribute_deco
rators.rb:28:in `add_user_provided_columns'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attributes.rb:
93:in `columns'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/attributes.rb:
98:in `columns_hash'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/querying.rb:41
:in `find_by_sql'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/relation.rb:63
8:in `exec_queries'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/relation.rb:54
:in `load'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/relation.rb:24
3:in `to_a'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/relation/deleg
ation.rb:46:in `map'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:8
43:in `get_all_versions'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:9
84:in `migrated'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:9
89:in `ran?'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:9
66:in `runnable'
org/jruby/RubyArray.java:2638:in `reject!'
org/jruby/RubyArray.java:2609:in `reject'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:9
66:in `runnable'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:9
51:in `migrate'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:8
19:in `up'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/migration.rb:7
97:in `migrate'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/tasks/database
_tasks.rb:137:in `migrate'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/activerecord-4.2.3/lib/active_record/railties/datab
ases.rake:44:in `(root)'
org/jruby/RubyProc.java:271:in `call'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/task.rb:240:in
`execute'
org/jruby/RubyArray.java:1613:in `each'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/task.rb:235:in
`execute'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/task.rb:179:in
`invoke_with_ca
ll_chain'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/1.9/monitor.rb:211:in
`mon_synchronize'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/task.rb:172:in
`invoke_with_ca
ll_chain'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/task.rb:165:in
`invoke'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:150:in
`invoke_
task'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:106:in
`top_lev
el'
org/jruby/RubyArray.java:1613:in `each'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:106:in
`top_lev
el'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:115:in
`run_wit
h_threads'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:100:in
`top_lev
el'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:78:in
`run'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:176:in
`standar
d_exception_handling'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/lib/rake/application.rb:75:in
`run'
/home/crush-157/.rvm/rubies/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.4.2/bin/rake:33:in
`(root)'
org/jruby/RubyKernel.java:1087:in `load'
/home/crush-157/.rvm/rubies/jruby-1.7.19//bin/rake:23:in `(root)'
Tasks: TOP => db:migrate


More information about the JRuby mailing list