Wednesday, 27 May 2009

ColdFusion (JRun) and JNDI mapping for JDBC and Mail Sessions

We have a situation where we're working on a ColdFusion project that will be deployed on glassfish (in production). Glassfish will use JNDI to manage all the connections to external resources (namely the databases and the mail server).

By default, ColdFusion ships with its own J2EE container (JRun) - so as the project began to take shape, we wanted to be able to create similar JNDI bindings within JRun - so we could closely mimic how the application would behave when deployed on glassfish.

I think I'm being fair saying the documentation for ColdFusion's JRun config files isn't exactly what you'd call the most comprehensive, so here's a rough list of the steps we took to set up JNDI mappings in ColdFusion for a JDBC[JNDI] datasource and for a mail server and what was required to get it all working:

Configuring ColdFusion to work with a JDBC datasource

1. Get the relevant Java JDBC driver for the database you're trying to use (for example, MS SQL Server would use sqljdbc4.jar) and put that jar into your Coldfusion lib folder (e.g. ColdFusion8/lib)

2. In the jrun-web.xml (/Applications/ColdFusion8/wwwroot/WEB-INF/jrun-web.xml), you need to declare the JNDI bindings before you can configure them, so the last few lines of your xml document should look like this:



N.B. make sure this is just above the closing tag (</jrun-web-app>)

3. In your jrun-resources.xml (/Applications/ColdFusion8/runtime/servers/coldfusion/SERVER-INF/jrun-resources.xml)



N.B. This should be just before the closing tag (</jrun-resources>)

An important note here should be that there should be a match between the names in the two files on:
<jndi-name>your-jndi-db-ref-name</jndi-name>
and
<jndi-name>your-jndi-db-ref-name</jndi-name>
respectively.

This should complete the binding for Coldfusion/JRun - restart ColdFusion and you should be good to go.

Configuring ColdFusion to work with a MailServer via JNDI

1. In the jrun-web.xml:



2. In your jrun-resources.xml:



As before, restart ColdFusion to test whether these changes worked.

Useful References:
http://www.adobe.com/support/jrun/working_jrun/jrun4_jndi_and_j2ee_enc/jrun4_jndi_and_j2ee_enc03.html
http://livedocs.adobe.com/jrun/4/descriptordocs/jrun-resources/jrun-resources.htm

Tuesday, 5 May 2009

Daisy CMS - Notes on updating Links as part of a Document Task

This needs to be expanded upon, but:



Works in Java... -1, -1 args seem to work for ensuring proper linkage between variant and branch ids


But if you're creating a Document Task using Javascript, get your document using:



This updates a load of link fields with the id of the specified linked Document (by Id).

Ref: http://www.nabble.com/Programmatically-create-a-link-%28VariantKey%29-td7687320.html#a7687320