jruby / activerecord-jdbc-adapter

JRuby's ActiveRecord adapter using JDBC.
BSD 2-Clause "Simplified" License
462 stars 386 forks source link

ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: relation "" does not exist #666

Closed mareczek closed 9 years ago

mareczek commented 9 years ago

Problem occurs with basic queries such as:

User.first

Setup: jruby

➜  project git:(master) ✗ rbenv version
jruby-9.0.0.0.pre2 (set by .ruby-version)

Gemfile.lock

GIT
  remote: git://github.com/jruby/activerecord-jdbc-adapter.git
  revision: 633fdca6bdc4ae9ebf970d24f75b01c354d4b5d9
  specs:
    activerecord-jdbc-adapter (1.4.0.dev-java)
      jar-dependencies (~> 0.1.13)
    jdbc-postgres (9.4.1200)

GIT
  remote: git://github.com/radar/paranoia.git
  revision: bb98963b0e38aef362e55afdc2ab7d5d7de3b564
  branch: rails4
  specs:
    paranoia (2.1.3)
      activerecord (~> 4.0)

GIT
  remote: git://github.com/seuros/capistrano-puma.git
  revision: 0efac45710b9fb65cb885aeeb4d6ea1247520c3e
  specs:
    capistrano3-puma (1.1.0)
      capistrano (~> 3.0)
      puma (>= 2.6)

GIT
  remote: git://github.com/seuros/capistrano-sidekiq.git
  revision: 7bc73100681805c88ef58bb6984ac48b8662241c
  specs:
    capistrano-sidekiq (0.5.3)
      capistrano
      sidekiq

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.1.12)
      actionpack (= 4.1.12)
      actionview (= 4.1.12)
      mail (~> 2.5, >= 2.5.4)
    actionpack (4.1.12)
      actionview (= 4.1.12)
      activesupport (= 4.1.12)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    actionview (4.1.12)
      activesupport (= 4.1.12)
      builder (~> 3.1)
      erubis (~> 2.7.0)
    active_model_serializers (0.9.3)
      activemodel (>= 3.2)
    activemodel (4.1.12)
      activesupport (= 4.1.12)
      builder (~> 3.1)
    activepesel (0.1.1)
      rails (>= 3.0.0)
    activerecord (4.1.12)
      activemodel (= 4.1.12)
      activesupport (= 4.1.12)
      arel (~> 5.0.0)
    activeresource (4.0.0)
      activemodel (~> 4.0)
      activesupport (~> 4.0)
      rails-observers (~> 0.1.1)
    activesupport (4.1.12)
      i18n (~> 0.6, >= 0.6.9)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.1)
      tzinfo (~> 1.1)
    ancestry (2.1.0)
      activerecord (>= 3.0.0)
    annotate (2.6.3)
      activerecord (>= 2.3.0)
      rake (>= 0.8.7)
    arel (5.0.1.20140414130214)
    axlsx (2.0.1)
      htmlentities (~> 4.3.1)
      nokogiri (>= 1.4.1)
      rubyzip (~> 1.0.0)
    bcrypt-ruby (3.0.1)
    bcrypt-ruby (3.0.1-java)
    builder (3.2.2)
    cancancan (1.12.0)
    capistrano (3.3.3)
      capistrano-stats (~> 1.0.3)
      i18n
      rake (>= 10.0.0)
      sshkit (~> 1.3)
    capistrano-bundler (1.1.4)
      capistrano (~> 3.1)
      sshkit (~> 1.2)
    capistrano-rails (1.1.3)
      capistrano (~> 3.1)
      capistrano-bundler (~> 1.1)
    capistrano-rbenv (2.0.3)
      capistrano (~> 3.1)
      sshkit (~> 1.3)
    capistrano-stats (1.0.3)
    carrierwave (0.10.0)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      json (>= 1.7)
      mime-types (>= 1.16)
    carrierwave-imageoptimizer (1.2.1)
      carrierwave (~> 0.8)
      image_optimizer (~> 1.2)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    coderay (1.1.0)
    colorize (0.7.7)
    connection_pool (2.2.0)
    database_cleaner (1.4.1)
    default_value_for (3.0.1)
      activerecord (>= 3.2.0, < 5.0)
    diff-lcs (1.2.5)
    email_validator (1.6.0)
      activemodel
    erubis (2.7.0)
    factory_girl (4.5.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.5.0)
      factory_girl (~> 4.5.0)
      railties (>= 3.0.0)
    faker (1.4.3)
      i18n (~> 0.5)
    fakeredis (0.5.0)
      redis (~> 3.0)
    ffi (1.9.10)
    ffi (1.9.10-java)
    figaro (1.1.1)
      thor (~> 0.14)
    foreigner (1.5.0)
      activerecord (>= 3.0.0)
    formatador (0.2.5)
    guard (2.12.8)
      formatador (>= 0.2.4)
      listen (>= 2.7, <= 4.0)
      lumberjack (~> 1.0)
      nenv (~> 0.1)
      notiffany (~> 0.0)
      pry (>= 0.9.12)
      shellany (~> 0.0)
      thor (>= 0.18.1)
    guard-compat (1.2.1)
    guard-rspec (4.6.2)
      guard (~> 2.1)
      guard-compat (~> 1.1)
      rspec (>= 2.99.0, < 4.0)
    hashie (2.1.2)
    hiredis (0.4.5)
    hiredis (0.4.5-java)
    hitimes (1.2.2)
    hitimes (1.2.2-java)
    htmlentities (4.3.4)
    i18n (0.7.0)
    image_optimizer (1.3.0)
    immigrant (0.1.5)
      activerecord (>= 3.0)
      foreigner (>= 1.2.1)
    jar-dependencies (0.1.15)
    jrjackson (0.2.9)
    json (1.8.3)
    json (1.8.3-java)
    listen (3.0.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    lumberjack (1.0.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    method_source (0.8.2)
    micro_token (0.0.3)
    mime-types (2.6.1)
    mini_portile (0.6.2)
    minitest (5.7.0)
    multi_json (1.11.2)
    nenv (0.2.0)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (2.9.2)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    nokogiri (1.6.6.2-java)
    normalizr (0.1.0)
    notiffany (0.0.6)
      nenv (~> 0.1)
      shellany (~> 0.0)
    nyan-cat-formatter (0.11)
      rspec (>= 2.99, >= 2.14.2, < 4)
    oj (2.12.10)
    oj_mimic_json (1.0.1)
    paper_trail (3.0.8)
      activerecord (>= 3.0, < 5.0)
      activesupport (>= 3.0, < 5.0)
    pdfkit (0.8.0)
    pg (0.18.2)
    polyamorous (1.1.0)
      activerecord (>= 3.0)
    pry (0.10.1)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
    pry (0.10.1-java)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
      spoon (~> 0.0)
    puma (2.6.0)
      rack (>= 1.1, < 2.0)
    puma (2.6.0-java)
      rack (>= 1.1, < 2.0)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rack (1.5.5)
    rack-cors (0.4.0)
    rack-protection (1.5.3)
      rack
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.1.12)
      actionmailer (= 4.1.12)
      actionpack (= 4.1.12)
      actionview (= 4.1.12)
      activemodel (= 4.1.12)
      activerecord (= 4.1.12)
      activesupport (= 4.1.12)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.1.12)
      sprockets-rails (~> 2.0)
    rails-api (0.4.0)
      actionpack (>= 3.2.11)
      railties (>= 3.2.11)
    rails-observers (0.1.2)
      activemodel (~> 4.0)
    railties (4.1.12)
      actionpack (= 4.1.12)
      activesupport (= 4.1.12)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    ransack (1.3.0)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      i18n
      polyamorous (~> 1.1)
    rb-fsevent (0.9.5)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    redis (3.0.7)
    redis-namespace (1.5.2)
      redis (~> 3.0, >= 3.0.4)
    rmagick (2.15.2)
    rmagick4j (0.3.9-java)
    roo (1.13.2)
      nokogiri
      rubyzip
      spreadsheet (> 0.6.4)
    rspec (3.3.0)
      rspec-core (~> 3.3.0)
      rspec-expectations (~> 3.3.0)
      rspec-mocks (~> 3.3.0)
    rspec-core (3.3.2)
      rspec-support (~> 3.3.0)
    rspec-expectations (3.3.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.3.0)
    rspec-mocks (3.3.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.3.0)
    rspec-rails (3.3.3)
      actionpack (>= 3.0, < 4.3)
      activesupport (>= 3.0, < 4.3)
      railties (>= 3.0, < 4.3)
      rspec-core (~> 3.3.0)
      rspec-expectations (~> 3.3.0)
      rspec-mocks (~> 3.3.0)
      rspec-support (~> 3.3.0)
    rspec-support (3.3.0)
    ruby-ole (1.2.11.8)
    rubyzip (1.0.0)
    seedbank (0.3.0)
    shellany (0.0.1)
    shoulda-matchers (2.8.0)
      activesupport (>= 3.0.0)
    sidekiq (3.4.1)
      celluloid (~> 0.16.0)
      connection_pool (>= 2.1.1)
      json
      redis (>= 3.0.6)
      redis-namespace (>= 1.3.1)
    sinatra (1.4.6)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (>= 1.3, < 3)
    slop (3.6.0)
    spoon (0.0.4)
      ffi
    spreadsheet (1.0.3)
      ruby-ole (>= 1.0)
    sprockets (3.2.0)
      rack (~> 1.0)
    sprockets-rails (2.3.2)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    squeel (1.2.2)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      polyamorous (~> 1.1.0)
    sshkit (1.7.1)
      colorize (>= 0.7.0)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    symbolize (4.4.1)
      activemodel (>= 3.2, < 5)
      activesupport (>= 3.2, < 5)
    thor (0.19.1)
    thread_safe (0.3.5)
    thread_safe (0.3.5-java)
    tilt (2.0.1)
    timers (4.0.1)
      hitimes
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    unicode_utils (1.4.0)
    wkhtmltopdf-binary (0.9.9.3)
    zip-zip (0.3)
      rubyzip (>= 1.0.0)

PLATFORMS
  java
  ruby

DEPENDENCIES
  active_model_serializers (~> 0.9.0)
  activepesel (= 0.1.1)
  activerecord (~> 4.1.6)
  activerecord-jdbc-adapter!
  activeresource (~> 4.0)
  ancestry
  annotate (= 2.6.3)
  axlsx
  bcrypt-ruby (~> 3.0.0)
  cancancan (~> 1.7)
  capistrano (= 3.3.3)
  capistrano-bundler (~> 1.1.2)
  capistrano-rails (~> 1.1)
  capistrano-rbenv (~> 2.0)
  capistrano-sidekiq!
  capistrano3-puma!
  carrierwave
  carrierwave-imageoptimizer
  database_cleaner
  default_value_for (~> 3.0.0)
  email_validator
  factory_girl_rails
  faker
  fakeredis
  figaro
  foreigner (= 1.5.0)
  guard-rspec
  hashie (~> 2.0)
  hiredis (~> 0.4.5)
  immigrant (= 0.1.5)
  jdbc-postgres
  jrjackson
  micro_token
  multi_json
  normalizr
  nyan-cat-formatter
  oj
  oj_mimic_json
  paper_trail
  paranoia!
  pdfkit
  pg
  puma (~> 2.6.0)
  quiet_assets
  rack-cors
  rails (~> 4.1.0)
  rails-api
  ransack (= 1.3.0)
  redis (~> 3.0.1)
  redis-namespace
  rmagick
  rmagick4j
  roo
  rspec-expectations
  rspec-rails
  seedbank (~> 0.3)
  shoulda-matchers
  sidekiq
  sinatra (>= 1.3.0)
  squeel (= 1.2.2)
  symbolize (= 4.4.1)
  unicode_utils (~> 1.4)
  wkhtmltopdf-binary
  zip-zip

BUNDLED WITH
   1.10.5

Stack trace:

NoMethodError: undefined method `[]' for nil:NilClass
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/relation/delegation.rb:9:in `relation_delegate_class'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/relation/delegation.rb:112:in `relation_class_for'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/relation/delegation.rb:106:in `create'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:133:in `table_name='
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:148:in `reset_table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:109:in `table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:343:in `compute_table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:148:in `reset_table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:109:in `table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/core.rb:148:in `arel_table'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/core.rb:164:in `relation'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/scoping/named.rb:33:in `default_scoped'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/scoping/named.rb:28:in `all'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/querying.rb:10:in `where'
    from (irb):2:in `<eval>'
    from org/jruby/RubyKernel.java:1005:in `eval'
    from org/jruby/RubyKernel.java:1315:in `loop'
    from org/jruby/RubyKernel.java:1125:in `catch'
    from org/jruby/RubyKernel.java:1125:in `catch'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/console.rb:90:in `start'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/console.rb:9:in `start'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands.rb:17:in `<top>'
    from org/jruby/RubyKernel.java:966:in `require'
    from bin/User.first
ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: relation "" does not exist
  Position: 293:         SELECT a.attname, format_type(a.atttypid, a.atttypmod),
               pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
          FROM pg_attribute a LEFT JOIN pg_attrdef d
            ON a.attrelid = d.adrelid AND a.attnum = d.adnum
         WHERE a.attrelid = '""'::regclass
           AND a.attnum > 0 AND NOT a.attisdropped
         ORDER BY a.attnum

ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: relation "" does not exist
  Position: 293
    from arjdbc/jdbc/RubyJdbcConnection.java:969:in `execute_query_raw'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-633fdca6bdc4/lib/arjdbc/jdbc/adapter.rb:495:in `block in exec_query_raw'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/connection_adapters/abstract_adapter.rb:378:in `block in log'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activesupport-4.1.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/connection_adapters/abstract_adapter.rb:372:in `log'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-633fdca6bdc4/lib/arjdbc/jdbc/adapter.rb:495:in `exec_query_raw'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-633fdca6bdc4/lib/arjdbc/jdbc/adapter.rb:502:in `select_rows'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-633fdca6bdc4/lib/arjdbc/postgresql/adapter.rb:1199:in `column_definitions'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-633fdca6bdc4/lib/arjdbc/postgresql/adapter.rb:1135:in `columns'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/connection_adapters/schema_cache.rb:93:in `block in prepare_default_proc'
    from org/jruby/RubyProc.java:303:in `call'
    from org/jruby/RubyHash.java:715:in `default'
    from org/jruby/RubyHash.java:1116:in `[]'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/connection_adapters/schema_cache.rb:44:in `columns'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:214:in `columns'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:223:in `columns_hash'
... 357 levels...
    from org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61)
    from org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
    from bin.rails.invokeOther6:require(bin/rails)
    from bin.rails.RUBY$script(bin/rails:4)
    from java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
    from org.jruby.ir.Compiler$1.load(Compiler.java:111)
    from org.jruby.Ruby.runScript(Ruby.java:830)
    from org.jruby.Ruby.runScript(Ruby.java:823)
    from org.jruby.Ruby.runNormally(Ruby.java:753)
    from org.jruby.Ruby.runFromMain(Ruby.java:575)
    from org.jruby.Main.doRunFromMain(Main.java:404)
    from org.jruby.Main.internalRun(Main.java:299)
    from org.jruby.Main.run(Main.java:226)
    from org.jruby.Main.main(Main.java:198)irb(main):004:0> 
mareczek commented 9 years ago

Forgot to add the database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: <%= ENV['DB_NAME'] %>
  host: localhost
  port: 5432
  pool: 5
  username: <%= ENV['DB_USER'] %>
  password:
mareczek commented 9 years ago

@kares do you thing it might have something to do with #667?

donv commented 9 years ago

@mareczek I think not since #667 is specific for ActiveRecord 4.2.x and involves calling reset_column_information.

kares commented 9 years ago

@mareczek will need a (hopefully simple) way to reproduce and/or more testing with changes such as :

mareczek commented 9 years ago

@donv do you think I found a bug or there's something wrong with my code? (with mri and pg gem it works)

mareczek commented 9 years ago

@kares I tried also with 1.7.20 - same thing

mareczek commented 9 years ago

Just changed activerecord-jdbc-adapter to use 1.3.17 and the result is the same stack trace:

irb(main):001:0> User.first
NoMethodError: undefined method `[]' for nil:NilClass
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/relation/delegation.rb:9:in `relation_delegate_class'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/relation/delegation.rb:112:in `relation_class_for'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/relation/delegation.rb:106:in `create'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:133:in `table_name='
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:148:in `reset_table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:109:in `table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:343:in `compute_table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:148:in `reset_table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/model_schema.rb:109:in `table_name'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/core.rb:148:in `arel_table'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/core.rb:164:in `relation'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/scoping/named.rb:33:in `default_scoped'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/scoping/named.rb:28:in `all'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/activerecord-4.1.12/lib/active_record/querying.rb:3:in `first'
    from (irb):1:in `<eval>'
    from org/jruby/RubyKernel.java:1005:in `eval'
    from org/jruby/RubyKernel.java:1315:in `loop'
    from org/jruby/RubyKernel.java:1125:in `catch'
    from org/jruby/RubyKernel.java:1125:in `catch'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/console.rb:90:in `start'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/console.rb:9:in `start'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/railties-4.1.12/lib/rails/commands.rb:17:in `<top>'
    from org/jruby/RubyKernel.java:966:in `require'
    from bin/rails:4:in `<top>'irb(main):002:0> 
GIT
  remote: git://github.com/jruby/activerecord-jdbc-adapter.git
  revision: 6f2c75284a394a2bacf31b07947708af5d5365aa
  tag: v1.3.17
  specs:
    activerecord-jdbc-adapter (1.3.17)
      activerecord (>= 2.2)

GIT
  remote: git://github.com/radar/paranoia.git
  revision: bb98963b0e38aef362e55afdc2ab7d5d7de3b564
  branch: rails4
  specs:
    paranoia (2.1.3)
      activerecord (~> 4.0)

GIT
  remote: git://github.com/seuros/capistrano-puma.git
  revision: 0efac45710b9fb65cb885aeeb4d6ea1247520c3e
  specs:
    capistrano3-puma (1.1.0)
      capistrano (~> 3.0)
      puma (>= 2.6)

GIT
  remote: git://github.com/seuros/capistrano-sidekiq.git
  revision: 7bc73100681805c88ef58bb6984ac48b8662241c
  specs:
    capistrano-sidekiq (0.5.3)
      capistrano
      sidekiq

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.1.12)
      actionpack (= 4.1.12)
      actionview (= 4.1.12)
      mail (~> 2.5, >= 2.5.4)
    actionpack (4.1.12)
      actionview (= 4.1.12)
      activesupport (= 4.1.12)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    actionview (4.1.12)
      activesupport (= 4.1.12)
      builder (~> 3.1)
      erubis (~> 2.7.0)
    active_model_serializers (0.9.3)
      activemodel (>= 3.2)
    activemodel (4.1.12)
      activesupport (= 4.1.12)
      builder (~> 3.1)
    activepesel (0.1.1)
      rails (>= 3.0.0)
    activerecord (4.1.12)
      activemodel (= 4.1.12)
      activesupport (= 4.1.12)
      arel (~> 5.0.0)
    activeresource (4.0.0)
      activemodel (~> 4.0)
      activesupport (~> 4.0)
      rails-observers (~> 0.1.1)
    activesupport (4.1.12)
      i18n (~> 0.6, >= 0.6.9)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.1)
      tzinfo (~> 1.1)
    ancestry (2.1.0)
      activerecord (>= 3.0.0)
    annotate (2.6.3)
      activerecord (>= 2.3.0)
      rake (>= 0.8.7)
    arel (5.0.1.20140414130214)
    axlsx (2.0.1)
      htmlentities (~> 4.3.1)
      nokogiri (>= 1.4.1)
      rubyzip (~> 1.0.0)
    bcrypt-ruby (3.0.1)
    bcrypt-ruby (3.0.1-java)
    builder (3.2.2)
    cancancan (1.12.0)
    capistrano (3.3.3)
      capistrano-stats (~> 1.0.3)
      i18n
      rake (>= 10.0.0)
      sshkit (~> 1.3)
    capistrano-bundler (1.1.4)
      capistrano (~> 3.1)
      sshkit (~> 1.2)
    capistrano-rails (1.1.3)
      capistrano (~> 3.1)
      capistrano-bundler (~> 1.1)
    capistrano-rbenv (2.0.3)
      capistrano (~> 3.1)
      sshkit (~> 1.3)
    capistrano-stats (1.0.3)
    carrierwave (0.10.0)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      json (>= 1.7)
      mime-types (>= 1.16)
    carrierwave-imageoptimizer (1.2.1)
      carrierwave (~> 0.8)
      image_optimizer (~> 1.2)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    coderay (1.1.0)
    colorize (0.7.7)
    connection_pool (2.2.0)
    database_cleaner (1.4.1)
    default_value_for (3.0.1)
      activerecord (>= 3.2.0, < 5.0)
    diff-lcs (1.2.5)
    email_validator (1.6.0)
      activemodel
    erubis (2.7.0)
    factory_girl (4.5.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.5.0)
      factory_girl (~> 4.5.0)
      railties (>= 3.0.0)
    faker (1.4.3)
      i18n (~> 0.5)
    fakeredis (0.5.0)
      redis (~> 3.0)
    ffi (1.9.10)
    ffi (1.9.10-java)
    figaro (1.1.1)
      thor (~> 0.14)
    foreigner (1.5.0)
      activerecord (>= 3.0.0)
    formatador (0.2.5)
    guard (2.12.8)
      formatador (>= 0.2.4)
      listen (>= 2.7, <= 4.0)
      lumberjack (~> 1.0)
      nenv (~> 0.1)
      notiffany (~> 0.0)
      pry (>= 0.9.12)
      shellany (~> 0.0)
      thor (>= 0.18.1)
    guard-compat (1.2.1)
    guard-rspec (4.6.2)
      guard (~> 2.1)
      guard-compat (~> 1.1)
      rspec (>= 2.99.0, < 4.0)
    hashie (2.1.2)
    hiredis (0.4.5)
    hiredis (0.4.5-java)
    hitimes (1.2.2)
    hitimes (1.2.2-java)
    htmlentities (4.3.4)
    i18n (0.7.0)
    image_optimizer (1.3.0)
    immigrant (0.1.5)
      activerecord (>= 3.0)
      foreigner (>= 1.2.1)
    jdbc-postgres (9.4.1200)
    jrjackson (0.2.9)
    json (1.8.3)
    json (1.8.3-java)
    listen (3.0.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    lumberjack (1.0.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    method_source (0.8.2)
    micro_token (0.0.3)
    mime-types (2.6.1)
    mini_portile (0.6.2)
    minitest (5.7.0)
    multi_json (1.11.2)
    nenv (0.2.0)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (2.9.2)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    nokogiri (1.6.6.2-java)
    normalizr (0.1.0)
    notiffany (0.0.6)
      nenv (~> 0.1)
      shellany (~> 0.0)
    nyan-cat-formatter (0.11)
      rspec (>= 2.99, >= 2.14.2, < 4)
    oj (2.12.10)
    oj_mimic_json (1.0.1)
    paper_trail (3.0.8)
      activerecord (>= 3.0, < 5.0)
      activesupport (>= 3.0, < 5.0)
    pdfkit (0.8.0)
    pg (0.18.2)
    polyamorous (1.1.0)
      activerecord (>= 3.0)
    pry (0.10.1)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
    pry (0.10.1-java)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
      spoon (~> 0.0)
    puma (2.12.1)
    puma (2.12.1-java)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rack (1.5.5)
    rack-cors (0.4.0)
    rack-protection (1.5.3)
      rack
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.1.12)
      actionmailer (= 4.1.12)
      actionpack (= 4.1.12)
      actionview (= 4.1.12)
      activemodel (= 4.1.12)
      activerecord (= 4.1.12)
      activesupport (= 4.1.12)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.1.12)
      sprockets-rails (~> 2.0)
    rails-api (0.4.0)
      actionpack (>= 3.2.11)
      railties (>= 3.2.11)
    rails-observers (0.1.2)
      activemodel (~> 4.0)
    railties (4.1.12)
      actionpack (= 4.1.12)
      activesupport (= 4.1.12)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    ransack (1.3.0)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      i18n
      polyamorous (~> 1.1)
    rb-fsevent (0.9.5)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    redis (3.0.7)
    redis-namespace (1.5.2)
      redis (~> 3.0, >= 3.0.4)
    rmagick (2.15.2)
    rmagick4j (0.3.9-java)
    roo (1.13.2)
      nokogiri
      rubyzip
      spreadsheet (> 0.6.4)
    rspec (3.3.0)
      rspec-core (~> 3.3.0)
      rspec-expectations (~> 3.3.0)
      rspec-mocks (~> 3.3.0)
    rspec-core (3.3.2)
      rspec-support (~> 3.3.0)
    rspec-expectations (3.3.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.3.0)
    rspec-mocks (3.3.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.3.0)
    rspec-rails (3.3.3)
      actionpack (>= 3.0, < 4.3)
      activesupport (>= 3.0, < 4.3)
      railties (>= 3.0, < 4.3)
      rspec-core (~> 3.3.0)
      rspec-expectations (~> 3.3.0)
      rspec-mocks (~> 3.3.0)
      rspec-support (~> 3.3.0)
    rspec-support (3.3.0)
    ruby-ole (1.2.11.8)
    rubyzip (1.0.0)
    seedbank (0.3.0)
    shellany (0.0.1)
    shoulda-matchers (2.8.0)
      activesupport (>= 3.0.0)
    sidekiq (3.4.1)
      celluloid (~> 0.16.0)
      connection_pool (>= 2.1.1)
      json
      redis (>= 3.0.6)
      redis-namespace (>= 1.3.1)
    sinatra (1.4.6)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (>= 1.3, < 3)
    slop (3.6.0)
    spoon (0.0.4)
      ffi
    spreadsheet (1.0.3)
      ruby-ole (>= 1.0)
    sprockets (3.2.0)
      rack (~> 1.0)
    sprockets-rails (2.3.2)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    squeel (1.2.2)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      polyamorous (~> 1.1.0)
    sshkit (1.7.1)
      colorize (>= 0.7.0)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    symbolize (4.4.1)
      activemodel (>= 3.2, < 5)
      activesupport (>= 3.2, < 5)
    thor (0.19.1)
    thread_safe (0.3.5)
    thread_safe (0.3.5-java)
    tilt (2.0.1)
    timers (4.0.1)
      hitimes
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    tzinfo-data (1.2015.5)
      tzinfo (>= 1.0.0)
    unicode_utils (1.4.0)
    wkhtmltopdf-binary (0.9.9.3)
    zip-zip (0.3)
      rubyzip (>= 1.0.0)

PLATFORMS
  java
  ruby

DEPENDENCIES
  active_model_serializers (~> 0.9.0)
  activepesel (= 0.1.1)
  activerecord (~> 4.1.6)
  activerecord-jdbc-adapter!
  activeresource (~> 4.0)
  ancestry
  annotate (= 2.6.3)
  axlsx
  bcrypt-ruby (~> 3.0.0)
  cancancan (~> 1.7)
  capistrano (= 3.3.3)
  capistrano-bundler (~> 1.1.2)
  capistrano-rails (~> 1.1)
  capistrano-rbenv (~> 2.0)
  capistrano-sidekiq!
  capistrano3-puma!
  carrierwave
  carrierwave-imageoptimizer
  database_cleaner
  default_value_for (~> 3.0.0)
  email_validator
  factory_girl_rails
  faker
  fakeredis
  figaro
  foreigner (= 1.5.0)
  guard-rspec
  hashie (~> 2.0)
  hiredis (~> 0.4.5)
  immigrant (= 0.1.5)
  jdbc-postgres
  jrjackson
  micro_token
  multi_json
  normalizr
  nyan-cat-formatter
  oj
  oj_mimic_json
  paper_trail
  paranoia!
  pdfkit
  pg
  puma (~> 2.12.0)
  quiet_assets
  rack-cors
  rails (~> 4.1.0)
  rails-api
  ransack (= 1.3.0)
  redis (~> 3.0.1)
  redis-namespace
  rmagick
  rmagick4j
  roo
  rspec-expectations
  rspec-rails
  seedbank (~> 0.3)
  shoulda-matchers
  sidekiq
  sinatra (>= 1.3.0)
  squeel (= 1.2.2)
  symbolize (= 4.4.1)
  tzinfo-data
  unicode_utils (~> 1.4)
  wkhtmltopdf-binary
  zip-zip

BUNDLED WITH
   1.10.5
kares commented 9 years ago

in that case its definitely a bug ... if you could isolate the User part for us for reproducing that would help

mareczek commented 9 years ago

I started my dev server and this is what's comming out:

Started GET "/api/auth/current_user?fields%5Blocations%5D%5B%5D=children&fields%5Busers%5D%5B%5D=current_roles&fields%5Busers%5D%5B%5D=available_events&fields%5Busers%5D%5B%5D=current_event&fields%5Busers%5D%5B%5D=current_location" for 0:0:0:0:0:0:0:1 at 2015-07-17 12:04:27 +0200
   (55.0ms)  SELECT version()

ArgumentError (wrong number of arguments (2 for 1)):
  activerecord (4.1.12) lib/active_record/relation/query_methods.rb:92:in `build_select'
  squeel (1.2.2) lib/squeel/adapters/active_record/4.1/relation_extensions.rb:92:in `build_arel'
  activerecord (4.1.12) lib/active_record/relation/query_methods.rb:842:in `arel'
  activerecord (4.1.12) lib/active_record/relation.rb:611:in `exec_queries'
  activerecord (4.1.12) lib/active_record/relation.rb:493:in `load'
  activerecord (4.1.12) lib/active_record/relation.rb:238:in `to_a'
  activerecord (4.1.12) lib/active_record/relation/delegation.rb:46:in `map'
  activerecord (4.1.12) lib/active_record/migration.rb:838:in `get_all_versions'
  activerecord (4.1.12) lib/active_record/migration.rb:849:in `needs_migration?'
  activerecord (4.1.12) lib/active_record/migration.rb:389:in `check_pending!'
  activerecord (4.1.12) lib/active_record/migration.rb:377:in `call'
  actionpack (4.1.12) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.12) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.12) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.1.12) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.1.12) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  actionpack (4.1.12) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.1.12) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.12) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.12) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.12) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.12) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.12) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.12) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  actionpack (4.1.12) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.5) lib/rack/runtime.rb:17:in `call'
  activesupport (4.1.12) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  rack (1.5.5) lib/rack/lock.rb:17:in `call'
  actionpack (4.1.12) lib/action_dispatch/middleware/static.rb:84:in `call'
  rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
  railties (4.1.12) lib/rails/engine.rb:514:in `call'
  railties (4.1.12) lib/rails/application.rb:144:in `call'
  rack (1.5.5) lib/rack/content_length.rb:14:in `call'
  puma-2.12.1 (java) lib/puma/server.rb:539:in `handle_request'
  puma-2.12.1 (java) lib/puma/server.rb:386:in `process_client'
  puma-2.12.1 (java) lib/puma/server.rb:269:in `block in run'
  org/jruby/RubyProc.java:303:in `call'
  puma-2.12.1 (java) lib/puma/thread_pool.rb:106:in `block in spawn_thread'

  Rendered /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/actionpack-4.1.12/lib/action_dispatch/middleware/templates/rescues/_source.erb (3.0ms)
  Rendered /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/actionpack-4.1.12/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (13.0ms)
  Rendered /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/actionpack-4.1.12/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (26.0ms)
  Rendered /Users/mark/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/actionpack-4.1.12/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (139.0ms)

I don't think specific to the User model. The same thing happens with all models. I think it's more of a low level bug. Any tips on debugging it?

donv commented 9 years ago

Start with making the smallest possible example that fails.

mareczek commented 9 years ago

With which rails version do you guys work?

mareczek commented 9 years ago

I found what's causing the problem. I'm using the great normalizr gem. It utilises the Module.prepend feature. It is supposed to be supported in jruby but it seems that in this case:

module Normalizr
  module Concern
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def normalize(*args, &block)
        options = Normalizr::OptionsParser.new(args, block)

        prepend Module.new {
          options.attributes.each do |method|
            define_method :"#{method}=" do |value|
              value = Normalizr.normalize(value, *options.pre)
              value = Normalizr.normalize(value, *options.post) if options.post.any?
              super(value)
            end
          end
        }
      end

      # attribute normalizer compatibility
      alias_method :normalize_attribute,  :normalize
      alias_method :normalize_attributes, :normalize
    end
  end
end

it produces some unexpected behaviour.

Any ideas where I should follow-up with the prepend Module.new {} issue?

kares commented 9 years ago

as noted already, try to come up with a smallest possible script (with a Gemfile) or Rails app and report at https://github.com/jruby/jruby/issues - you'll get better advice on JRuby internals such as prepend there. before doing so make sure you tried 9.0.0.0 final release and taht it works on MRI 2.2.2.

svenfuchs commented 9 years ago

Since I found this via Google ... upgrading activerecord-jdbc-adapter and using JRuby 9.0.3.0 fixed this for me.