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.
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 ?
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 ?
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?:
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.
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?:
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’
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 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.
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 ?
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.