So now that I got PostgreSQL configured as a resource with the
javax.sql.DataSource interface, I'd like to go one step further and
configure it as a javax.sql.XADataSource.
According to the PostgreSQL JDBC FAQ, XA support was added in
8.1dev-403:
http://jdbc.postgresql.org/documentation/faq.html
You can see the javadoc for the org.postgresql.xa package here:
http://jdbc.postgresql.org/development/privateapi/index.html
So this configuration works:
<Resource name="jdbc/whisper_db"
auth="Container"
type="javax.sql.DataSource"
url="jdbc:postgresql://127.0.0.1:5432/my_db"
driverClassName="org.postgresql.Driver"
username="----------------"
password="----------------"
maxWait="3000"
maxIdle="100"
maxActive="10" />
But this configuration doesn't (the only difference is the type set
to XADataSource):
<Resource name="jdbc/whisper_db"
auth="Container"
type="javax.sql.XADataSource"
url="jdbc:postgresql://127.0.0.1:5432/my_db"
driverClassName="org.postgresql.Driver"
username="----------------"
password="----------------"
maxWait="3000"
maxIdle="100"
maxActive="10" />
Trying to specify the type as an XADataSource gives me an exception
with a javax.naming.NamingException at the root:
Caused by: javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.ResourceFactory.getObjectInstance
(ResourceFactory .java:132)
at javax.naming.spi.NamingManager.getObjectInstance
(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
792)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:
152)
at org.apache.naming.SelectorContext.lookup
(SelectorContext.java:136)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.solarmetric.conf.Configurations.lookup
(Configurations.java:643)
... 82 more
I know Tomcat doesn't have a transaction manager, but I'm planning to
use the Jencks library ( http://jencks.org/ ) which enables web-apps
deployed in Tomcat to use JTA (Jencks uses Geronimo's transaction
manager) and get distributed transactions. As I understand it, one of
the steps in that process is configuring the database as an
XADataSource via JNDI. I would have expected to simply be able to
switch types, but that doesn't seem to work. Any thoughts?
Mark
On Apr 5, 2006, at 10:42 AM, Farrow, Marc wrote:
That is correct. ResourceLink is for linking in Global resources
(DataSources, Environment Entries, etc) that are defined in the
Server.xml
file.
-----Original Message-----
From: Mark Slater [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 05, 2006 1:40 PM
To: Tomcat Users List
Subject: Re: PostgreSQL access via JNDI
My mis-capitalization of DataSource was the main problem. Also, I was
trying to use Resource and ResourceLink in META-INF/context.xml;
ResourceLink is apparently not needed if the Resource is local to the
webapp.
Thank you both for your help!
Mark
On Apr 5, 2006, at 5:11 AM, Hadraba Petr wrote:
Hi,
I'm successfuly using PostgreSQL 8.1.3 with Tomcat 5.5.15 with JDBC
drivers 405 (build)...
I have the <Resource ... /> definition in the META-INF/context.xml
and
in the WEB-INF/web.xml I have the <resource-ref/> element. The
<resource-env-ref/> I'm using for the ActiveMQ client connection.
Also the JDBC drivers are placed in the common/lib directory.
If you search the list, you will find my previous posts containing
all
the configuration files.
Have a lot of fun!
PETR
On 4/5/06, Amila Suriarachchi <[EMAIL PROTECTED]> wrote:
On 4/5/06, Mark Slater <[EMAIL PROTECTED]> wrote:
I've been trying to get PostgreSQL set up to be accessed through
JNDI
in Tomcat 5.5.x. I found the docs page describing it, "jndi-
datasource-examples-howto.html", and followed the example there,
but
it still doesn't work. I'm trying to provide access to
PostgreSQL for
use by both JDO and JCR in my web-apps.
Here's the Resource definition I'm using:
<Resource name="jdbc/whisper_db"
auth="Container"
type="javax.sql.Datasource "
S should be capital as well DataSource
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]