After many attempts, it seems that the combination xa-datasource <-> postgres driver does not support a failover configuration with non default port(5432). I guess, that the driver does not implements all methods expected by xa.
I'd be glad if somebody can show me that I'm wrong about that...
This example is working, but use the default port:
<xa-datasource jndi-name="java:/Foo" pool-name="Foo" enabled="true" use-ccm="true" statistics-enabled="true">
<xa-datasource-property name="url">
jdbc:postgresql://server1,server2/db_name
</xa-datasource-property>
<xa-datasource-property name="ApplicationName">
MyApp
</xa-datasource-property>
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<driver>postgresql-jdbc4</driver>
<url-delimiter>,</url-delimiter>
<xa-pool>
<min-pool-size>6</min-pool-size>
<max-pool-size>40</max-pool-size>
<prefill>true</prefill>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>foo</user-name>
<password>blah</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>3000</blocking-timeout-millis>
<idle-timeout-minutes>60</idle-timeout-minutes>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>