Forum: JRuby JRuby and Sqlite3

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D0976c8374e3ea238aa7e104ae2605f8?d=identicon&s=25 Roderich T. (roderich)
on 2015-02-28 16:05
I want to compile my ruby application into a jar File.

Now there I get a strange error using jdbc/sqlite3.

This is my ruby (test) code:

require 'rubygems'
require 'jdbc/sqlite3'
require 'java'

import org.sqlite.JDBC

connection = java.sql.DriverManager.getConnection
  statement = connection.createStatement
    statement.executeUpdate("insert into user values ('test', 7)")
    rs = statement.executeQuery("select * from user")
      puts "user\tpass"
        puts ["#{rs.getString(1)}",

There are no problems using jruby directly, but when I include the
script in jruby-complete.jar using "jar ufe myapp.jar
org.jruby.JarBootstrapMain jar-bootstrap.rb", I always get an error when
I start it ( java -jar myapp.jar ):

NameError: missing class or uppercase package name (`org.sqlite.JDBC')
54147c1a1223b425d4f4f7947c9bba46?d=identicon&s=25 Ariel Valentin (Guest)
on 2015-02-28 16:23
(Received via mailing list)
Does your jar contain all of the dependencies? Or are they located
somewhere else?

Sent from my mobile device. Please excuse any errors.
D0976c8374e3ea238aa7e104ae2605f8?d=identicon&s=25 Roderich T. (roderich)
on 2015-02-28 16:27
The jar file is a raw "jruby-complete.jar" containing no dependencies.

All necessary gem files are located in a subfolder "gems" with the
ENV['GEM_PATH'] variable pointing on it.

Caa2df9372ffa0a9e95b2bab1e8fea34?d=identicon&s=25 Karol Bucek (Guest)
on 2015-02-28 16:48
(Received via mailing list)
require 'jdbc/sqlite3' does not auto-load the driver class:
D0976c8374e3ea238aa7e104ae2605f8?d=identicon&s=25 Roderich T. (roderich)
on 2015-02-28 17:03
@Karol: thanks for your hint.

But the problem still exists. I downloaded the sqlite-jdbc.jar. I put in
in my classpath AND included it in my myapp.jar file.

But the result is:
DBI::DatabaseError: java.sql.SQLException: No suitable driver found
D0976c8374e3ea238aa7e104ae2605f8?d=identicon&s=25 Roderich T. (roderich)
on 2015-02-28 17:31
Problem solved!

I made a mistake by including sqlite-jdbc into the main jar file.

Thanks to all!
4080b90a5ce9d67fd84fdf5faded3e77?d=identicon&s=25 Cloudrck Tech (cloudrck)
on 2015-04-10 06:24
Forgive my ignorance, but I'm new to JRuby. What is the reason for
requiring "rubygems", I don't see any specific code that uses a gem.
C0cb3aadb9a66d00df16686f4a1fc312?d=identicon&s=25 Tim Uckun (Guest)
on 2015-04-10 06:27
(Received via mailing list)
rubygems allows you to be able to require the other libs in your script.
Basically it tells your script which directories to load your libs from.

These days people mostly use bundler though.
2c0c4cf3ccc8da22f7c3b9586ce1cd70?d=identicon&s=25 Christian MICHON (Guest)
on 2015-04-10 08:08
(Received via mailing list)
you still need to call rubygems before you call bundler anyway...
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2015-04-10 08:12
(Received via mailing list)
in newer ruby version including jruby there is no need to require
"rubygems" it is already required.

if you do not want rubygems from a jruby commandline execution then you
need to explicitly tell jruby not to require it:

jruby -Xcli.rubygems.enable=false -e "p require 'rubygems'"


On Fri, Apr 10, 2015 at 11:36 AM, Christian MICHON <
This topic is locked and can not be replied to.