users@glassfish.java.net

Re: JDBC via JNDI from Tomcat to Glassfish and back

From: <glassfish_at_javadesktop.org>
Date: Thu, 19 Apr 2007 01:59:29 PDT

Instead of "java:/comp/env/jdbc/postgres"
can you try
"java:comp/env/jdbc/postgres" (no / after java: )

http://java.sun.com/products/jndi/tutorial/beyond/misc/policy.html

Also, you must have resource-ref in "sun-web.xml"

 <resource-ref>
        <res-ref-name>jdbc/postgres</res-ref-name>
        <jndi-name>jdbc/ACTUAL_RESOURCE_NAME</jndi-name>
        <default-resource-principal>
            <name>USER</name>
            <password>PASSWORD</password>
        </default-resource-principal>
      </resource-ref>
where jdbc/ACTUAL_RESOURCE_NAME is the name by which resource is created.

and web.xml will refer as,

 <resource-ref>
        <res-ref-name>jdbc/postgres</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>


Now the application can do look up as, "java:comp/env/jdbc/postgres"

https://glassfish.dev.java.net/javaee5/docs/DG/beanr.html

Thanks,
-Jagadish
[Message sent by forum member 'jr158900' (jr158900)]

http://forums.java.net/jive/thread.jspa?messageID=213100