Hello.
Here is my database.yml:
production:
adapter: jdbc
jndi: java:comp/env/mydb
driver: postgresql
encoding: unicode
wait_timeout: 5
pool: 5
and here is my tomcat configuration:
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="xxx" password="xxx"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://svso.example.com:5432/my_db"/>
I deploy the war under tomcat but I've this error:
org.jruby.rack.RackInitializationException: jdbc adapter requires
driver class and url
What I've missed?
Thank you.
on 2012-12-27 09:42
on 2012-12-27 09:49
Mauro - I'm not certain, but I access Postgres through JDBC, and I have this in my database.yml: adapter: jdbcpostgresql and have the following in my Gemfile: gem 'activerecord-jdbc-adapter' gem 'jdbc-postgres' - Keith --- Keith R. Bennett http://about.me/keithrbennett
on 2012-12-27 10:03
On 27 December 2012 09:48, Keith Bennett <keithrbennett@gmail.com> wrote: > Mauro - > > I'm not certain, but I access Postgres through JDBC, and I have this in my database.yml: > > adapter: jdbcpostgresql > > …and have the following in my Gemfile: > > gem 'activerecord-jdbc-adapter' > gem 'jdbc-postgres' Do you use a jndi connection?
on 2012-12-27 11:09
This works for running our application under Tomcat with a Postgres
database:
production:
adapter: jdbc
jndi: java:comp/env/jdbc/cxo
pool: 99999
I suspect your failure comes from specifying "driver". The Ruby
connection code does not need to know the underlying driver. Tomcat
takes care of that. Notice that your error message is coming from the
Ruby, not from Tomcat.
Also, here is my commit message for setting "pool" very large:
The activerecord-jdbc-adapter does not pool JNDI database
connections.
This is a good thing. The JNDI database connection provider
(Tomcat)
is handling connection pooling. What activerecord-jdbc-adapter does
not do is prevent activerecord from imposing its own limit on
database
connections. We depend on Tomcat to enforce the connection limit.
So, we tell activerecord to allow essentially an infinite number of
database connections.
on 2012-12-27 11:33
On 27 December 2012 11:08, Bruce Adams <bruce.adams@acm.org> wrote: > Notice that your error message is coming from the Ruby, not from Tomcat. I've found instructions here: https://gist.github.com/1560215 and is specified driver: postgresql in database.yml configuration. However now I try without driver parameter.
on 2012-12-27 11:42
Oops, no, sorry, I don't. Never mind ;) - Keith --- Keith R. Bennett http://about.me/keithrbennett
on 2012-12-27 12:04
On 27 December 2012 11:32, Mauro <mrsanna1@gmail.com> wrote: >> code does not need to know the underlying driver. Tomcat takes care of that. >> Notice that your error message is coming from the Ruby, not from Tomcat. > > I've found instructions here: https://gist.github.com/1560215 and is > specified driver: postgresql in database.yml configuration. > However now I try without driver parameter. Ok, without the driver parameter it works, thank you very much. I think https://gist.github.com/1560215 must be updated.
on 2012-12-27 17:06
Sorry it was a false alarm.
The error still exists:
My database.yml:
production:
adapter: jdbc
jndi: java:comp/env/jdbc/my_db
encoding: unicode
wait_timeout: 5
pool: 99999
The error:
org.jruby.rack.RackInitializationException: jdbc adapter requires
driver class and url
tomcat context.xml
<Resource name="jdbc/my_db" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="xxx" password="xxx"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://svsopsql01.comune.cagliari.loc:5432/my_db"/>
What I've missed again?
on 2012-12-27 17:22
Just some idea: If I were you, I would first ensure that the JDBC DataSource is successfully created by Tomcat, and successfully exposed in its JDNI space (in other words, ensure that what you want to consume is existing and available - in the Java domain - as a first step; and as a second step - try to see whether the JRuby client is able to find it). I would open some JConsole session, or use other means of establishing JMX connection with the Tomcat, and then browse over Catalina's MBeans to see whether the DataSource exists. Another possible way to check this, of course, is to make some simple Proof-Of-Concept Java consumption from inside a small web application that the DS is available (lookup should be sufficient). Why am I saying all this ? Mainly because Tomcat's proprietary way of configuration data sources has always been not-that-friendly to me, and I used to have similar problems - not getting the exact configuration. Have you checked this ? It will help you to find out where is the problem - in Tomcat's configuration, or at the client side - in AR-JDBC adapter. Next, you have the ActiveRecord-JDBC adapter. I see that you have specified "adapter: jdbc" although you are using a PostgreSQL server behind - maybe you have some good reasons for doing that ? Cheers, Krum.
on 2012-12-27 17:25
On 27 December 2012 17:21, Krum Bakalsky <kpym.kgb@gmail.com> wrote: > > Next, you have the ActiveRecord-JDBC adapter. I see that you have specified > "adapter: jdbc" although you are using a PostgreSQL server behind - maybe > you have some good reasons for doing that ? I've found a how to here, https://gist.github.com/1560215. As you can see the adapter parameter in database.yml is jdbc.
on 2012-12-27 17:44
I agree with Krum. I'd imagine that even if Java handles the data base connections, the Active Record code needs to know about the underlying data base implementation, for example so that it can generate the correct SQL for that DB. Maybe you could try the jdbcpostgresql adapter from the jdbc-postgres gem, as I described in my previous message, and see if that works?: >> >> adapter: jdbcpostgresql >> >> and have the following in my Gemfile: >> >> gem 'activerecord-jdbc-adapter' >> gem 'jdbc-postgres' > - Keith --- Keith R. Bennett http://about.me/keithrbennett
on 2012-12-27 17:46
I agree with Krum. I'd imagine that even if Java handles the data base connections, the Active Record code needs to know about the underlying data base implementation, for example so that it can generate the correct SQL for that DB. Maybe you could try the jdbcpostgresql adapter from the jdbc-postgres gem, as I described in my previous message, and see if that works?: >> >> adapter: jdbcpostgresql >> >> and have the following in my Gemfile: >> >> gem 'activerecord-jdbc-adapter' >> gem 'jdbc-postgres' > - Keith --- Keith R. Bennett http://about.me/keithrbennett
on 2012-12-27 17:54
So when you specify the driver: postgres in your database.yml, and include the following in your Gemfile: gem 'activerecord-jdbcpostgresql-adapter' gem 'jruby-openssl' you still get the same error? If you've done the former (database.yml), but not the latter, I wonder if that could explain the absence of a class name to correspond to the driver name. - Keith
on 2012-12-27 18:20
Now: production: adapter: jdbcpostgresql jndi: java:comp/env/jdbc/albofornitori driver: postgresql encoding: unicode wait_timeout: 5 pool: 5 error: org.jruby.rack.RackInitializationException: The driver encountered an unknown error: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgresql://svsopsql01.xxx:5432/albo_fornitori'
on 2012-12-27 18:21
On 27 December 2012 18:19, Mauro <mrsanna1@gmail.com> wrote: > error: > > org.jruby.rack.RackInitializationException: The driver encountered an > unknown error: Cannot create JDBC driver of class > 'org.postgresql.Driver' for connect URL > 'jdbc:postgresql://svsopsql01.xxx:5432/albo_fornitori' I've the gems in my Gemfile.
on 2012-12-27 18:47
OK, so we've reached the JDBC URL. Could you now test this URL via some client - be it some GUI for SQL interaction with the data base, or a standalone Java client program, or whatever ? Maybe you miss some port, or other tricky detail for that URL. What does a fast Googling about similar issues with the Postgre arjdbc adapter show ? Or with JDBC access to Postgre in general - maybe you use an old version of the JDBC driver. And, just for completeness, did you check that the DS is there in JNDI ?
on 2012-12-27 19:06
I researched this a little, and found that this error could occur if the JDBC driver jar file is not available/found, but the JDBC Postgres gem contains it, so it doesn't seem to be that. I do think we're making progress, though, and checking that URL with another client is a great idea. - Keith --- Keith R. Bennett http://about.me/keithrbennett
on 2012-12-28 09:45
On 27 December 2012 19:05, Keith Bennett <keithrbennett@gmail.com> wrote: > I researched this a little, and found that this error could occur if the > JDBC driver jar file is not available/found, but the JDBC Postgres gem > contains it, so it doesn't seem to be that. > > I do think we're making progress, though, and checking that URL with another > client is a great idea. After trying more times I think I've found the problem. It's my fault. Under tomcat I've more than one application, each using it's own database. So I put all jndi definitions under context.xml that is loaded for each web application. That is wrong, every application must have it's own context definition.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.