Note that there are some explanatory texts on larger screens.

plurals
  1. POJNDI datasource to oracle with grails 1.3
    primarykey
    data
    text
    <p>I can't get my JNDI datasource running. Followed the official grails doc I set up a datasouce in Config.groovy:</p> <pre><code>grails.naming.entries = [ "mydatasource": [ type: "javax.sql.DataSource", auth: "Container", description: "Development Datasource", url: "jdbc:oracle:oci:@mydb", username: "user", password: "pass", maxActive: "8", maxIdle: "4" ] ] </code></pre> <p>So, my DataSource.groovy looks like:</p> <pre><code>pooled = false jndiName = "mydatasource" </code></pre> <p>I tried for "mydatasource" several different notations like "jdbc/mydatasource" or "java:comp/env/jdbc/mydatasource".</p> <p>With every configuration I receive this: "javax.naming.NameNotFoundException: Name ... is not bound in this Context".</p> <p>Also when I set up a global resource in the server.xml of my tomcat 6, the deployed grails-war cannot find the JNDI resource.</p> <p>Any ideas to get this stuff working?</p> <p>Thx</p> <hr> <p>Edit:</p> <p>It works fine! Tomcat (version 6 in my case) adds automatically the prefix "java:comp/env" to your datasource jndi-name. So does the tomcat plugin in grails.</p> <p>Grails Config.groovy (in my case for development environment):</p> <pre><code>grails.naming.entries = [ "jdbc/mydb": [ type: "javax.sql.DataSource", auth: "Container", description: "Development Datasource", driverClassName: "oracle.jdbc.driver.OracleDriver", url: "jdbc:oracle:oci:@mydb", username: "user", password: "pass", maxActive: "8", maxIdle: "4" ] ] </code></pre> <p>In context.xml (in my case for production environment):</p> <pre><code>&lt;Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:oci:@mydb" username="user" password="pass" maxActive="50" maxIdle="10" maxWait="5000"/&gt; </code></pre> <p>In DataSource.groovy</p> <pre><code>pooled = false jndiName = "java:comp/env/jdbc/mydb" </code></pre> <hr> <p>Edit:</p> <p>A weird thing if you use the datasource as a global resource. The configuration which works for me:</p> <p>In server.xml:</p> <pre><code>&lt;Resource name="java:comp/env/jdbc/mydb" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:oci:@mydb" username="user" password="pass" maxActive="50" maxIdle="10" maxWait="5000"/&gt; </code></pre> <p>In context.xml</p> <pre><code>&lt;ResourceLink name="jdbc/mydb" global="java:comp/env/jdbc/mydb" type="javax.sql.DataSource" /&gt; </code></pre> <p>In DataSource.groovy:</p> <pre><code>pooled = false jndiName = "java:comp/env/jdbc/mydb" </code></pre>
    singulars
    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