|
Home > Archive > WebSphere Application Server > August 2006 > How to consistently JNDI name a datasource
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to consistently JNDI name a datasource
|
|
|
| We do our development under Tomcat, but deploy to WAS for test and production.
The databases in each environment are different.
Under Tomacat we use JNDI to get the datasource as java:comp/env/jdbc/theDataSource. However, for deployment to WebSphere (using a datasource define in WAS) we need to reference it as just jdbc/theDataSource.
This means modification of the config file in the war as part of deployment. This is a bad, error-prone practice (we already had one production deployment failure due to it).
I found a reference on how to do this for EJBs, but unfortunately it is specific to EJBs. How can I do this consistently for datasources.
One particular problem for us is that we use Spring to manage the datasource so we have no control over the getContext or datasource code.
This seems very basic to good development/deployment practices.
Thanks for any help,
-- Frank
| |
|
| > Under Tomacat we use JNDI to get the datasource as
java:comp/env/jdbc/theDataSource. However, for deployment to WebSphere
(using a datasource define in WAS) we need to reference it as just
jdbc/theDataSource.
Looks like you're missing a Resource Reference entry in web.xml.
Normally, the code should contain "java:comp/env/jdbc/theDataSource" and the
Deployment Descriptor a Resource Reference for "jdbc/theDataSource". When
you install the application, there is a page to map "jdbc/theDataSource"
(name choosen by the developer) to a name choosen by the administrator, so
the DataSource can be defined as "jdbc/SomeDataSource" in the Administrative
Console.
| |
|
|
|
|
|