Note that there are some explanatory texts on larger screens.

plurals
  1. POJetty datasource with Atomikos UserTransaction
    primarykey
    data
    text
    <p>I have two datasources in my Web application (principalDB and backupDB) on two Postgresql DBs, and a web container managed transaction manager (with Atomikos) for them. Spring FW and Hibernate are my building blocks for the application. The problem I am running into is that Jetty 6.1.3 web container does not seem to load the app specific WEB-INF/jetty-env.xml that declares the resources so I am getting an exception:</p> <pre> Caused by: javax.naming.NameNotFoundException; remaining name 'env/jdbc/principalDB' at org.mortbay.naming.NamingContext.lookup(NamingContext.java:634) at org.mortbay.naming.NamingContext.lookup(NamingContext.java:665) at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680) at org.mortbay.naming.java.javaRootURLContext.lookup(javaRootURLContext.java:112) at javax.naming.InitialContext.lookup(InitialContext.java:351) at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155) at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88) at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153) at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:200) at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:186) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) ... 43 more</pre> <p>Here is how I configured the two datasources</p> <ol> <li><p>in the <code>WEB-INF/web.xml</code> I have declared the two resources with resource-ref as:</p> <pre><code>&lt;resource-ref&gt; &lt;description&gt;The principal datasource&lt;/description&gt; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt; &lt;res-auth&gt;Container&lt;/res-auth&gt; &lt;res-ref-name&gt;jdbc/principalDB&lt;/res-ref-name&gt; &lt;/resource-ref&gt; &lt;resource-ref&gt; &lt;description&gt;The backup datasource&lt;/description&gt; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt; &lt;res-auth&gt;Container&lt;/res-auth&gt; &lt;res-ref-name&gt;jdbc/backupDB&lt;/res-ref-name&gt; &lt;/resource-ref&gt; </code></pre></li> <li><p>in the <code>WEB-INF/jetty-env.xml</code> I have</p> <p> </p> <pre><code>&lt;New id="principalDB" class="org.mortbay.jetty.plus.naming.Resource"&gt; &lt;Arg&gt;&lt;Ref id="wac"/&gt;&lt;/Arg&gt; &lt;Arg&gt;jdbc/principalDB&lt;/Arg&gt; &lt;Arg&gt; &lt;New class="com.atomikos.jdbc.nonxa.NonXADataSourceBean"&gt; &lt;Set name="driverClassName"&gt;org.postgresql.jdbc3.Jdbc3ConnectionPool&lt;/Set&gt; &lt;Set name="ServerName"&gt;localhost&lt;/Set&gt; &lt;Set name="PortNumber"&gt;5432&lt;/Set&gt; &lt;Set name="DatabaseName"&gt;first&lt;/Set&gt; &lt;Set name="Url"&gt;jdbc:postgresql://localhost:5432/first&lt;/Set&gt; &lt;Set name="user"&gt;test&lt;/Set&gt; &lt;Set name="password"&gt;password&lt;/Set&gt; &lt;/New&gt; &lt;/Arg&gt; &lt;/New&gt; &lt;New id="backupDB" class="org.mortbay.jetty.plus.naming.Resource"&gt; &lt;Arg&gt;&lt;Ref id="wac"/&gt;&lt;/Arg&gt; &lt;Arg&gt;jdbc/backupDB&lt;/Arg&gt; &lt;Arg&gt; &lt;New class="com.atomikos.jdbc.nonxa.NonXADataSourceBean"&gt; &lt;Set name="driverClassName"&gt;org.postgresql.jdbc3.Jdbc3ConnectionPool&lt;/Set&gt; &lt;Set name="ServerName"&gt;localhost&lt;/Set&gt; &lt;Set name="PortNumber"&gt;5432&lt;/Set&gt; &lt;Set name="DatabaseName"&gt;second&lt;/Set&gt; &lt;Set name="Url"&gt;jdbc:postgresql://localhost:5432/second&lt;/Set&gt; &lt;Set name="user"&gt;testSec&lt;/Set&gt; &lt;Set name="password"&gt;password&lt;/Set&gt; &lt;/New&gt; &lt;/Arg&gt; &lt;/New&gt; </code></pre> <p></p></li> </ol> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload