New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LoadError: load error: META-INF/main -- java.sql.SQLException: No suitable driver found for jdbc:postgresql #186
Comments
Some articles I read say to execute... I assume the JRuby equivalent is: In (JRuby) IRB, it looks like it helps (see pre/post postgresql jar file include): $ irb
jruby-1.7.4 :001 > Java::JavaClass.for_name("org.postgresql.Driver")
NameError: cannot load Java class org.postgresql.Driver
from org/jruby/javasupport/JavaClass.java:1242:in `for_name'
from (irb):1:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1489:in `loop'
from org/jruby/RubyKernel.java:1254:in `catch'
from org/jruby/RubyKernel.java:1254:in `catch'
from /Users/Eric/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'
jruby-1.7.4 :002 > require './lib/postgresql-8.4-703.jdbc4.jar'
=> true
jruby-1.7.4 :003 > Java::JavaClass.for_name("org.postgresql.Driver")
=> class org.postgresql.Driver But when I add that line to my main app, and create a Jar, the problem persists (same error). |
I extracted the contents of the created jar file, and grep'd for Jars.. $ jar xf test.jar
$ find . | grep -i \.jar$
./bundler/gems/warbler-75fc2de2f4c1/lib/warbler_jar.jar
./bundler/gems/warbler-75fc2de2f4c1/spec/sample_jar
./bundler/gems/warbler-75fc2de2f4c1/spec/sample_jar/bin/another_jar
./bundler/gems/warbler-75fc2de2f4c1/spec/sample_jar/bin/sample_jar
./gems/activerecord-jdbc-adapter-1.3.0/lib/arjdbc/jdbc/adapter_java.jar
./gems/atomic-1.1.13-java/lib/atomic_reference.jar
./gems/jdbc-postgres-9.2.1002.1/lib/postgresql-9.2-1002.jdbc3.jar
./gems/jdbc-postgres-9.2.1002.1/lib/postgresql-9.2-1002.jdbc4.jar
./gems/jruby-jars-1.7.4/lib/jruby-core-1.7.4.jar
./gems/jruby-jars-1.7.4/lib/jruby-stdlib-1.7.4.jar
./gems/jruby-rack-1.1.13.2/lib/jruby-rack-1.1.13.2.jar
./gems/json-1.8.0-java/lib/json/ext/generator.jar
./gems/json-1.8.0-java/lib/json/ext/parser.jar
./gems/nokogiri-1.6.0-java/lib/isorelax.jar
./gems/nokogiri-1.6.0-java/lib/jing.jar
./gems/nokogiri-1.6.0-java/lib/nekodtd.jar
./gems/nokogiri-1.6.0-java/lib/nekohtml.jar
./gems/nokogiri-1.6.0-java/lib/nokogiri/nokogiri.jar
./gems/nokogiri-1.6.0-java/lib/xercesImpl.jar
./gems/thread_safe-0.1.2-java/lib/thread_safe/jruby_cache_backend.jar
./META-INF/lib/jruby-core-1.7.4.jar
./META-INF/lib/jruby-stdlib-1.7.4.jar
./test/lib/postgresql-8.4-703.jdbc4.jar
./test/lib/postgresql-9.2-1003.jdbc4.jar
./test.jar Does it look like the postgresql Jars are in the correct directory? |
I extracted the warble'd jar, copied the postgresql jars from ./test/lib to ./META-INF/lib/, and recompressed the Jar. |
I had the exact same issue, but with the SQL Server jdbc driver. I found that if I modify config/warble.rb and include my jar in config.java_libs, then warbler copies (doesn't move) my jar from lib into META-INF/lib.
Seeing as how this is a configuration option, this probably isn't a bug that needs to be fixed. |
this is a common issue when using "raw" JDBC drivers and Warbler can not do anything about it ... we recommend using database: postgresql (instead of "jdbc") with AR/Rails or for "raw" usage the driver gems (if applicable) e.g. |
I am trying to use warble to create a JAR, which happens to use a postgresql driver jar to connect to Amazon RedShift.
When I create the jar and execute, I get the following exception:
I separated the connectivity code to demonstrate that it works prior to creating the Jar. Current files:
File contents: main.rb
Execution output using JRuby (JIT compiled):
$ ./main.rb ["file:/opt/test/./lib/postgresql-9.2-1003.jdbc4.jar"] Done.
Jar creation:
Jar execution:
Any thoughts on why this might not be working?
Perhaps related to this? https://github.com/jruby/jruby/wiki/FAQs#why-do-i-get-classnotfoundexception-when-i-call-javalangclassforname-from-ruby
Environment notes:
The text was updated successfully, but these errors were encountered: