Rails5 jruby not able to start - jruby

Not able to start rails5 with jruby, getting the following error.
gavinyap#gavin-ubuntu  ~/Development/rails5app  rails s
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from require at bin/rails:4)
Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-jdbcmysql-adapter'.
Gem Load Error is: uninitialized constant ActiveRecord::ConnectionAdapters::Column::Format
Backtrace for gem load error is:
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:13:in `<module:TypeCast>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:7:in `<module:Jdbc>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:4:in `< module:ConnectionAdapters>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:3:in `<top>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/column.rb:1:in `singleton cla
Versions of Jruby and Rails
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f
OpenJDK 64-Bit Server
VM 25.91-b14 on 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14 +jit [linux-x86_64]
Rails 5.0.0

The ActiveRecord JDBC gem has not been updated for Rails 5. Checking the project in GitHub shows some development activity early this year but there is no indication when a new gem will be released for Rails 5.

add gem 'activerecord-jdbcmysql-adapter', '~> 5.0.pre1' to your gemfile

Related

NameError: cannot load Java class com.mysql.jdbc.Driver

I'm using JRuby 1.7.2, along with DataMapper, and I'm getting an error I can't find an answer to.
I'm just testing out DataMapper along with MySQL 5.5 to see if it will run fine when I build around it. Here's the file I'm testing:
require "data_mapper"
require "keys"
DataMapper.setup(:default, "mysql://#{$user}:#{$pass}#localhost/test_db")
And when I run this, I get the error:
NameError: cannot load Java class com.mysql.jdbc.Driver
And it points to the DataMapper.setup line.
My Gemfile should be alright:
source :rubygems
gem "sinatra"
gem "trinidad"
gem "data_mapper"
# do a `sudo apt-get install libmysqlclient-dev` first
gem "dm-mysql-adapter"
gem "jdbc-mysql"
Is there anything I'm missing? I have MySQL set up with a user/pass locally already.
This is a common error when running JDBC clients for MySQL. You need to make sure you have mysql-connector-java-bin.jar on the classpath. You can download it from here.
I'm using Rails 3.2.9 and to solve the problem I added this to my application.rb
if defined? JRUBY_VERSION
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
end
actually, the correct answer is to work-around an incompatibility between 5.1.13 and 5.1.22 !
jdbc-mysql gem already contains the mysql-connector.jar it just ain't auto-loading anymore :
https://github.com/jruby/activerecord-jdbc-adapter/tree/master/jdbc-mysql (read the README)
you can also force the driver to auto-load using a Java system property e.g. from a cmd line :
jruby -J-Darjdbc.mysql.autoload=true -S rake ...
I had the same error when trying to use a mysql database from jruby/rails4. In my case this line was missing from ./Gemfile:
gem 'jdbc-mysql'

NoMethodError: undefined method `init' for Mysql:Class in rails after updating to ubuntu 12.04

After I updated to ubuntu 12.10, I started getting this error:
NoMethodError: undefined method `init' for Mysql:Class
I am using the mysql adapter.
% gem install mysql
solved the problem. Note that this gem was installed already even before I updated the ubuntu version but somehow the setup got messed up in the update.

JRuby JDBC-mysql error

I have JRuby + Swing application and want to add jdbc/mysql there
require "jdbc/mysql"
But when I'm trying to run it, I have the followig error:
LoadError: no such file to load -- jdbc/mysql
require at org/jruby/RubyKernel.java:1033
(root) at olap_frontend.rb:3
My gem list:
*** LOCAL GEMS ***
activerecord-jdbc-adapter (1.2.2)
activerecord-jdbcmysql-adapter (1.2.2)
bouncy-castle-java (1.5.0146.1)
bundler (1.1.3 ruby)
jdbc-mysql (5.1.13)
jruby-launcher (1.0.12 java)
jruby-openssl (0.7.6.1)
rake (0.9.2, 0.8.7)
rubygems-bundler (0.3.0 ruby)
What I'm doing wrong?
It was my fault - I need to require rubygems first

Wordpress to Jekyll script throwing error

I've been wrestling with this problem for a day or so and cannot figure out what's going on. I'm trying to run a script to import my Wordpress .sql into Jekyll and convert everything to markdown. But every time I run the script (on both Mac and Ubuntu) I'm getting an error. I'm at a loss of what to do. Here's my terminal output and gem list:
jason#ubuntu:~$ ruby -r './wordpress.rb' -e 'Jekyll::WordPress.process( "#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': LoadError: no such file to load -- mysql (Sequel::AdapterNotFound)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/adapters/mysql.rb:4
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `k_require'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:249:in `tsk_require'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:72:in `check_requiring_thread'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:69:in `synchronize'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:69:in `check_requiring_thread'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:249:in `tsk_require'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/database/connecting.rb:25:in `adapter_class'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/database/connecting.rb:63:in `connect'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:119:in `connect'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:282:in `adapter_method'
from /var/lib/gems/1.8/gems/sequel-3.22.0/lib/sequel/core.rb:289:in `mysql'
from ./wordpress.rb:35:in `process'
from -e:1
jason#ubuntu:~$ gem list
*** LOCAL GEMS ***
classifier (1.3.3)
directory_watcher (1.4.0)
fast-stemmer (1.0.0)
jekyll (0.10.0)
liquid (2.2.2)
maruku (0.6.0)
sequel (3.22.0)
syntax (1.0.0)
I'm using Paul Stamatiou's adapted script. Thanks ahead of time for any suggestions!
If you focus on the actual error message:
LoadError: no such file to load -- mysql
It's fairly obvious that you need to install the mysql gem:
gem install mysql

Help with MySQL gem on OSX

I'm trying to get the mysql gem working on OSX 10.5.6, and feeling stymied.
% gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed
% irb -rubygems -rmysql
irb> Mysql.init
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Users/rampion/.gem/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup
dyld: Symbol not found: _mysql_init
Referenced from: /Users/rampion/.gem/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup
zsh: trace trap irb -rubygems -rmysql
%
I'm using the default install of ruby 1.8.6.
I'm using a 64-bit version of MySQL 5.0.77. mysqld is running and I can use the mysql shell, so I suspect my issue is with mysql.gem, though I'm by no means certain.
Can anyone offer any advice?
Ok. So the solution turned out to be I needed to be runing the 32-bit version of MySQL 5.0.77 in order for mysql.gem to work.