I have a WAR that runs peachy under Tomcat 5.
In WEB-INF/context.xml, I have a DBPool configured.
<Context path="/cmsstr">
<Resource auth="Container" driverClassName="org.postgresql.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/postgres" password="password" type="javax.sql.DataSource" url="jdbc:postgresql://localhost:5432/mydb" username="dbuser"/>
</Context>
In my WAR, I look up my data source like this:
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/postgres");
However, when I try to deploy this to Glassfish v1b14, I can not seem to duplicate the "java:/comp/env/jdbc/postgres". Glassfish won't let me use the ':'.
Now, I'm not particularly passionate about what name I use, but I would like to know if there is a way I can configure both Tomcat and Glassfish so that I can run this code unchanged, using any name.
I tried a ctx.lookup("jdbc/postgres"), but Tomcat couldn't find that, while Glassfish could.
To be fair this aspect of JNDI has always been a wee bit cloudy to me regarding naming, default naming, required naming, etc.
But if anyone could point the way to getting a common configuration, I'd appreciate it.
[Message sent by forum member 'whartung' (whartung)]
http://forums.java.net/jive/thread.jspa?messageID=213077