July 25, 2015
Configuring JNDI Data sources in ColdFusion
Comments
(4)
July 25, 2015
Configuring JNDI Data sources in ColdFusion
(4)

(Originally written in Jul 2015, updated in Jan 2021)

For a more complete and updated discussion of this topic, see the 2019 post, Guide to configure JNDI datasource in ColdFusion.

This 2015 post below expanded on a still-older one, linked to below. Both are combined and updated into the more recent post.

For configuring JNDI data sources, it should firstly be supported by the application server.

Tomcat server, which is built-into ColdFusion server, has the support for this by default.

While there is a blog here on this how to configure, I want to explain few mistakes that are tend to be done while configuring.

One common mistake generally done is when the data source is configured from the ColdFusion administrator by
providing irrelevant    username/password. You may tend to provide Database’s username/password. This is NOT
Database’s username/password. It is the application server’s username and password on which data
source is configured. It should be left blank when the credentials are not required by the
server.

Prepending java:comp/env/ is required for the actual JNDI name that is registered in xml while registering the name in administrator.

It is not mandatory that you register the JNDI data source in ColdFusion administrator.

As long as the app server supports JNDI, you can invoke the data source that is configured in the application server in cfm source code directly either in case of standalone installation or EAR/WAR deployment. But for consistency and preferred names that can used in ColdFusion should be registered in ColdFusion.

This is applicable to both ColdFusion 10 and ColdFusion 11.

4 Comments
2023-07-27 18:11:01
2023-07-27 18:11:01

We deploy CF archive (.EAR) files on Websphere, and use the JNDI datasource setup in webshpere.
We have been doing that using CF2016, but with CF2021 we have been seeing the issues listed below.
1) In ColdFusion2016 we didn’t have to add a jndi Datasource or any datasource in the package, and the application connected successfully to the datasource configured on Websphere.
In CF2021, ColdFusion app is not able to connect to the Websphere DS and we get the error “The system has attempted to use an undefined value ….”
2) So, back to CF2021 Admin, I created a jndi datasource, and packaged it with the EAR, and now the application connects successfully to the jndi data source configured on websphere, great!
HOWEVER! the process to create a jndi datasource and package it with the archive file does not work consistently. Often times the jndi datasource does not get packaged with the archive. I keep attempting to create a new jndi DS until it works.
I need to be able to consistently create a CF2021 archive which pacakages JNDI data source. Something is wrong with creating a JNDI in CF2021 from the CF Admin page.

Like
(1)
>
laheeba19017529
's comment
2023-07-28 03:18:59
2023-07-28 03:18:59
>
laheeba19017529
's comment

Laheeba, could you please elaborate on two of your final points above: first, you say, “Often times the jndi datasource does not get packaged with the archive.”

I assume you are using the CF admin packaging&deployment page’s feature to create the war, based on what’s in that Cf admin. Is that right? And so you’re saying you have dsn x in that admin, then create a war, and load that war into websphere, and the cf admin for THAT war is missing that dsn x?

And then as for your last point, “I keep attempting to create a new jndi DS until it works”, I again will assume you mean in the new cf admin for the newly created war, once deployed. Is that right? If so, when you “create” it, what doesn’t “work”? The cf admin dsn page will always verify a newly created dsn (and there’s a button to verify any one or all). Does it verify? Does it work if called with code like cfquery? And does the dsn remain or somehow disappear? It just isn’t clear what you’re seeing. 

I realize you’re facing a very frustrating situation. Sorry for only asking questions rather than offering answers. Hoping your answers may better help us help you.

(And before you may ask, no, I am unable to confirm your experience of having to create a dsn when you did not need to in cf2016. I don’t have websphere implemented. Perhaps someone else–Adobe or not–may reply who does.) 

Like
2019-07-30 13:03:27
2019-07-30 13:03:27

*Corrected the broken link with the working article.

Like
(1)
>
Priyank Shrivastava
's comment
2019-11-21 18:45:13
2019-11-21 18:45:13
>
Priyank Shrivastava
's comment

For interested readers, the “working” post is here: https://coldfusion.adobe.com/2019/07/guide-configure-jndi-datasource-coldfusion/. Thanks for offering the corrected version, Priyank.

Like
(1)
Add Comment