Note that there are some explanatory texts on larger screens.

plurals
  1. POJNDI Resource Definition in Apache Tomcat 6
    primarykey
    data
    text
    <p>I'm more than inexperienced with Apache Tomcat, so forgive me if it's a trivial question I'm asking. </p> <p>My task is to change a rather big program so that it uses the connection from Tomcat instead of its own bean, so that you don't have to rebuild the code when the database changes. </p> <p>This is the original bean definition (slightly changed - passwords and such...):</p> <pre><code>&lt;bean id="ProjectDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="singleton"&gt; &lt;property name="url" value="jdbc:as400://127.0.0.1/TEST2;prompt=false;naming=sql;errors=full;date format=usa;date separator=/;time format=hms;time separator=:;transaction isolation=read committed;"/&gt; &lt;property name="driverClassName" value="com.ibm.as400.access.AS400JDBCDriver"/&gt; &lt;property name="username" value="asdf"/&gt; &lt;property name="password" value="asdf"/&gt; &lt;property name="initialSize" value="${ProjectDS.initialSize}"/&gt; &lt;property name="maxActive" value="${ProjectDS.maxActive}"/&gt; &lt;property name="maxIdle" value="${ProjectDS.maxIdle}"/&gt; &lt;property name="minIdle" value="${ProjectDS.minIdle}"/&gt; &lt;property name="testOnBorrow" value="${ProjectDS.testOnBorrow}"/&gt; &lt;property name="removeAbandoned" value="${ProjectDS.removeAbandoned}"/&gt; &lt;property name="removeAbandonedTimeout" value="${ProjectDS.removeAbandonedTimeout}"/&gt; &lt;property name="logAbandoned" value="${ProjectDS.logAbandoned}"/&gt; &lt;/bean&gt; </code></pre> <p>After reading several tutorials about Tomcat configuration, I did the following:</p> <p>The new bean:</p> <pre><code>&lt;bean id="ProjectDS" class="org.springframework.jndi.JndiObjectFactoryBean"&gt; &lt;property name="jndiName"&gt; &lt;value&gt;ProjectDS&lt;/value&gt; &lt;/property&gt; &lt;property name="resourceRef" value="true"&gt;&lt;/property&gt; &lt;/bean&gt; </code></pre> <p>server.xml :</p> <pre><code>&lt;Resource name="ProjectDS" global="ProjectDS" auth="Container" type="org.apache.commons.dbcp.BasicDataSource" driverClassName="com.ibm.as400.access.AS400JDBCDriver" url="jdbc:as400://127.0.0.1/TEST2" username="asdf" password="asdf" /&gt; </code></pre> <p>context.xml:</p> <pre><code>&lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt; &lt;ResourceLink global="ProjectDS" name="ProjectDS" type="org.apache.commons.dbcp.BasicDataSource"/&gt; </code></pre> <p>What I get is: </p> <blockquote> <p>Exception processing Global JNDI Resources javax.naming.NamingException: Cannot create resource instance</p> </blockquote> <p>I read somewhere that I shouldn't put the above into the server.xml but into the web.xml, but I don't know where exactly. Could that be the problem? </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.
 

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