Re: PostgreSQL (XADataSource) as Tomcat Resource

Lists: pgsql-jdbc
From: "Guy Rouillier" <guyr(at)masergy(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: PostgreSQL (XADataSource) as Tomcat Resource
Date: 2006-04-05 21:43:40
Message-ID: CC1CF380F4D70844B01D45982E671B230137A843@mtxexch01.add0.masergy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

markds75 wrote:
> How can I get Postgres to be deployed in Tomcat's JNDI as an
> XADataSource?
>
> I'm running my web app in Tomcat, and I'm moving towards distributed
> transactions for my two data sources (JDO and JCR). I've got the
> Jencks library providing JTA support (based on Geronimo's
> TransactionManager) within Tomcat. Currently, I have Postgres
> configured as a local web-app Resource as follows:
>
> <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" />
>
> The web-app is able to start up without errors in this case and
> things function as expected. However, I've been told that I should be
> using an XADataSource if I want JDO to participate in distributed
> transactions (specifically, I'm trying to get 2 phase commit). When I
> change the type to "javax.sql.XADataSource", the web-app fails to
> start because Tomcat cannot create the JNDI entry. I'm running under
> Java 1.5, so to my knowledge XADataSource is included.

What does the Tomcat log tell you when it tried to start up this as an
XADatasource? Did it provide any error message? I've not set up an
XADatasource in Tomcat, but under JBoss you need to provide additional
statements to define an XADatasource.

>
> Any pointers would be appreciated.
>
> Thanks,
> Mark
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

--
Guy Rouillier


From: "markds75" <markds75(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PostgreSQL (XADataSource) as Tomcat Resource
Date: 2006-04-05 21:55:04
Message-ID: 1144274104.592002.247140@v46g2000cwv.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

The only error is the exception (the Tomcat thrown exception is at the
bottom):

Caused by: <1|true|4.0.0EA4> kodo.util.InternalException: There was an
error when invoking the static getInstance method on the named factory
class "class kodo.jdbc.kernel.JDBCBrokerFactory". See the nested
exception for details.
at kodo.kernel.Bootstrap.getBrokerFactory(Bootstrap.java:96)
at
kodo.jdo.PersistenceManagerFactoryImpl.getPersistenceManagerFactory(PersistenceManagerFactoryImpl.java:43)
... 61 more
Caused by:
com.solarmetric.apache.commons.lang.exception.NestableRuntimeException:
There was an error duing JNDI lookup of the name
"java:comp/env/jdbc/whisper_db".
at
com.solarmetric.conf.Configurations.lookup(Configurations.java:647)
at
kodo.conf.KodoConfigurationImpl.lookupConnectionFactory(KodoConfigurationImpl.java:1277)
at
kodo.conf.KodoConfigurationImpl.getConnectionFactory(KodoConfigurationImpl.java:1259)
at
kodo.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:886)
at
kodo.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:609)
at
kodo.jdbc.meta.MappingDefaultsImpl.setConfiguration(MappingDefaultsImpl.java:825)
at
com.solarmetric.conf.Configurations.configureInstance(Configurations.java:292)
at
com.solarmetric.conf.Configurations.configureInstance(Configurations.java:243)
at
com.solarmetric.conf.PluginValue.instantiate(PluginValue.java:115)
at
com.solarmetric.conf.PluginValue.instantiate(PluginValue.java:105)
at
kodo.jdbc.conf.JDBCConfigurationImpl.getMappingDefaultsInstance(JDBCConfigurationImpl.java:728)
at
kodo.jdbc.meta.MappingRepository.<init>(MappingRepository.java:29)
at
kodo.jdbc.conf.JDBCConfigurationImpl.getMetaDataRepository(JDBCConfigurationImpl.java:749)
at
kodo.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:683)
at
kodo.kernel.AbstractBrokerFactory.pool(AbstractBrokerFactory.java:631)
at
kodo.jdbc.kernel.JDBCBrokerFactory.getInstance(JDBCBrokerFactory.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at kodo.kernel.Bootstrap.getBrokerFactory(Bootstrap.java:89)
... 62 more
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


From: "markds75" <markds75(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PostgreSQL (XADataSource) as Tomcat Resource
Date: 2006-04-06 01:26:06
Message-ID: 1144286766.570183.15660@j33g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Also, I just noticed that in some examples for other databases, the
Resource tag has a "factory" parameter too. Is there an appropriate
value (class) for a Postgres connection factory?

Mark