Recent Posts

dynamic variable names

//note, in cf documentation – You can combine text and variable names to construct a variable name on the left side of an =
//To construct a variable name this way, all the text on the left side of the equal sign must be in quotation marks.
//The left side of an assignment can’t be a function (So Evaluate wouldn’t work’)

“local.criteria.#local.keysToStruct[local.i]#”=Evaluate(“arguments.criteria.” & #local.keysToStruct[local.i]#);
break;

Configure webDav in IIS over SSL using windows authentication, but allow read access for all internet users

Note: To set up webDAV, here is a good article (If your using IIS 5.0 it is most likely already up and running):
http://www.windowsnetworking.com/articles_tutorials/WebDAV-IIS.html

The following article was good, but I thought it would be better to just use multiple virtual directories rather than multiple IIS sites.

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19095

What I did:
1)make a virtual directory imagesUploads that requires SSL and windows authentication and points to the uploads/images folder on the server. Allow write/modify/etc. in IIS.
2)make a virtual directory images, which points to the same uploads/images folder, but does not require SSL or windows login, just anonymous user read access in IIS.
3)On the uploads/images physical folder, give the upload users all the write/modify access they may need. Give the IUSR anonymous internet user account read only rights.
4)Users upload using webDAV and the URL yourdomain.com/imagesUploads, but your stuff will all point yourdomain.com/images

The retarded thing is, that is a user tries to access the non-ssl upload site, windows will still prompt for a login, and will deny them no-matter what, because it is not SSL. but I wonder if the uname/pw text is being sent, because that would make network sniffers pickup the credentials.

Receiving Flex Objects in Coldfusion, coldfusion component argument types

Flex Remoting with Coldfusion. Coldfusion Services and custom objects/components

I was getting frustrated when I COULD NOT receive a flex object as anything when a coldfusion service was receiving a remote call from flex. The coldfusion component had a method I was sending a call to. This method expected a struct arguement and then I was trying the argument type as on object. When I passed in the flex object to the remote method call in flex, when coldfusion received the argument it was breaking it apart and treating it as a messed up argument collection. Turns out you have to wrap a flex object in another object for coldfusion to receive it as a struct. Why the lack of documentation on this? I think flex remoting is really cool, but maybe it is a newer wave of development that just hasn’t been very popularized yet. I think that is changing.

In any case the following links really help with understanding how coldfusion and flex work together with remoting. Coldfusion components, like custom TO objects, can also be used across the wire, and vice-versa with flex objects. It is pretty slick, but you have to learn how to make coldfusion components and corresponding flex objects with properties that match, etc.

Nice article by Joel.

http://www.joelconnett.com/flexobjectstocoldfusion.html

I had originally found the following, which was helpful:

http://codingmurloc.wordpress.com/2007/05/15/passing-object-to-a-cfc-flex-or-cf-bug/

For custom component types, see also:

http://www.brucephillips.name/blog/index.cfm/2006/10/26/Exchaning-User-Defined-Objects-Between-ColdFusion-and-Flex

http://www.forta.com/blog/index.cfm/2006/2/1/The-Keys-To-Getting-CFC-ActionScript-AutoConversions-To-Work

Flex DataGrid rows. Does the selected item’s index in the dataprovider ArrayCollection change when the grid is re-sorted?

Yes.

For example, if I have 4 rows displaying user info, if the first row’s user has a name of ‘Kato’, the dataproviderUserArrayCollection[0].name = “Kato”.

What happens when I resort the rows by userNumber (or something) and Kato’s row is the third row? Is the the index of Kato’s Object in the array collection 0 or 2? It’s 2.

The array shifts to match the datagrid’s visual display (factuality, I’m sure the data model itself changes before the visual rendering is response to a click on a column title). So if Kato’s row moved from first place to third, so did his dataprovider array position. dataproviderUserArrayCollection[0].name = “Kato” shifted to dataproviderUserArrayCollection[2].name = “Kato”.

Dynamic argument list with coldfusion methods using argumentCollection

Check out the link, and learn how to use pass arguments to Coldfusion methods using the argumentCollection as your parameter. This is slick.

I was doing the following, concatenating my argument list to change with logic. I should have been using an argument struct instead of a clumsy string that was being evaluated like this:


<!--- This is a not so cool approach--->
<cfscript>
argsColl = "";
argsColl &= "username=Almonzo,";
argsColl &= "password="LauRa123";
authorized = securityCFC.getAuth(Evaluate(argsColl));
</cfscript>

The following was so much cooler, cut my code down, and made it so I didn’t have to figure out why the Evaluate function won’t evaluate strings with commas:)


<cfscript>
argsColl = structNew();
argsColl.username = "Almonzo";
argsColl.password = "LauRa123";
authorized = securityCFC.getAuth(argumentCollection = argsColl);
</cfscript>

Helpful link:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_28.html

Beware the affect of the base href= on AJAX requests, and IE. Permission denied to call XMLHttpRequest open method

The base href effect on XMLHtttpRequest.open (in IE)

Imagine that. If your base href is set to something weird, the ajax requests will get Access errors indicating “Permission Denied to call method yourXMLHttpRequestObject.open” Errors! But only in IE.

In IE, with AJAX requests, your url root must match your base href. base ref=”http://www.mydomain.com should be the same as the base url in xmlHttp.open(“GET”, “http://www.mydomain.com/MyRemoteServices/MyRemoteOrderService.cfc?
method=getOrderInfoXML&userid=1234”, true), or you can use relative urls.

Example I had:


//The XMLHttpRequest is named xmlHttp here, xmlHttp = new XMLHttpRequest()
//If the base href is set to something other than the server root, the AJAX request
//thinks the request is coming from a different server, or something.
//Permission denied to call XMLHttp.open with the following
//SET IN HTML HEAD <base href="http://www.mydomain.com/index.cfm?event=myOrder" /> - NOT HTTPS!
xmlHttp.open("GET", "https://mydomain.com/MyRemoteServices/MyRemoteOrderService.cfc?
method=getOrderInfoXML&userid=1234" , true);

//Now when the base href is set to the server root, no problems
//SET IN HTML HEAD <base href="https://www.mydomain.com/"> - HTTP!
xmlHttp.open("GET", "https://mydomain.com/MyRemoteServices/MyRemoteOrderService.cfc?
method=getOrderInfoXML&userid=1234" , true);

Issues when www isn’t mapped to your home url

Another issue that can happen with access denied errors with your AJAX request is when your www doesn’t resolve to the same url as your root. I.E. http://www.yourdomain.com isn’t the same dns entry as http://ourdomain.com, even if they both eventually go to the same server ip.

Error: Happens when your session is in http://www.yourdomain.com and your AJAX request points to http://yourdomain.com (if your www subdomain doesn’t resolve to http://yourdomain.com).


//I'm on a http:://www.mydomain.com page, and I get an error with this line
xmlHttp.open("GET", "http://mydomain.com/MyRemoteServices/MyRemoteOrderService.cfc?
method=getOrderInfoXML&userid=1234" , true);
// I'm on a http:://mydomain.com page, this line will work
xmlHttp.open("GET", "http://mydomain.com/MyRemoteServices/MyRemoteOrderService.cfc?
method=getOrderInfoXML&userid=1234" , true);

Multiple Coldfusion Instances as Windows Services using Multiple JVM configs and Debugger Settings

Summary:

Setting up each coldfusion server instance as a Windows service using its own jvm.config. Using the debugger with multiple coldfusion server instances causes errors unless you specify a separate debugger port in a unique jvm.config file for each instance.

First Note: If you can live with having no server instances running when you initially start windows, you can just start your cf server instance using the command line, with the -config option pointing to a custom config. The rest of this article focuses on setting up multiple jvm.configs, each coldfusion instance having a different jvm.config, and setup as a Windows services that can automatically start in windows.

jrun -config jvm.config_new_server -start default

After getting the following error repeatedly, I decided to stop putting up with running multiple coldfusion instances from one jvm.config file.

FATAL ERROR in native method: JDWP No transports initialized,

jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)

ERROR: transport error 202: bind failed: Address already in use

ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)

JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized

[../../../src/share/back/debugInit.c:690]

This error stemmed from me having multiple Coldfusion server instances, and every time I started one it would throw errors that a port was already in use (The debugger port). All my instances were setup to use the same debugger port, since they all used the same jvm.config file. I got sick of remembering to stop debugging services, or edit the JVM.config to not run the debugger each time I started a different CF Instance. Obviously there are many reasons for using separate jvm.configs, notably for allocating memory resources and settings to be shared more efficiently. Here is my step-by-step process for setting up multiple coldfusion server instances to run with multiple jvm.config xml files.

Note: If you use debugging with the default server, but do not change the default server instance to use its own jvm.config, from what I can tell, it still starts up fine, even though a port in use error shows up. I think this is because the admin server and the default instance server are both using the default jvm.config, but the admin server must not really cause enough of a clash to prevent the default instance from starting, since the admin server probably does not do that much with the debugger port. I need to explore what exactly the admin instance does. It is not as full blown as the other instances, and it must just serve as a shell or base that manages the other instances.

1)Go to Windows Admin Tools -> Services. Locate the name of Coldfusion Instances that are running as services. On my computer, these services show up as “Macromedia JRun Admin Server”, “Macromedia JRun CFusion Server” (The default instance, which for me was called cfusion) and “Adobe Coldfusion 8 AS cfusion2” (I set up another server instance called ‘cfusion2’). You need to remove all services for which you want to have a debugger. This way, you can remake the service with the option to use a specific and custom JVM. For example, you could have all instances use the default jvm.config, except for one.

2)Remove the non-default services that aren’t configured to use a custom JVM (unless you want the services already installed to just use the default JVM). Do this by using the jrunsvc.exe from the command line. Same folder as the default jvm.config. For me this was c:\JRun4\bin. So once you know the name of the services you want to remove, the command goes like this:

jrunsvc -remove “Adobe Coldfusion 8 AS cfusion2”

Don’t forget the quotes if there are spaces in the Service Name.

3)Install the instances as services, each one using the -config option to point to a custom JVM.config of your creation. Here are the commands I issued:

I left the default instance alone, and made the default JVM config contain the settings I wanted for the first and default instance (jvm.config). Here is the command for installing the second coldfusion instance as a service with a config file cfusion2.jvm.config:

jrunsvc -install cfusion2 cfusion2Service “cfusion2 Service” “This is the service for
the coldfusion server instance cfusion2” -config C:\Jrun4\bin\cfusion2jvm.config

And if you had a third instance, you could do

jrunsvc -install cfusion3 cfusion3Service “cfusion3 Service” “This is the service for
the coldfusion server instance cfusion3” -config C:\Jrun4\bin\cfusion3jvm.config

I know, very original naming. The install option is followed by 3 namings for the new service of my server instance. I think these are 1)service name 2)service display name 3)service description. These are arbitrary names and descriptions that the jrunsvc command has you set.

Note: I originally had the config option point to -config cfusion3jvm.config, but my service wasn’t getting my debugger port started, and I think it may have been using the jvm.config instead of the custom one. I changed -config cfusion3jvm.config to -config C:\Jrun4\bin\cfusion3jvm.config and it worked fine. Maybe I didn’t need to do that and I was just missing something though.

Note: If you try and start the service and get the ‘Windows could not start the service … review the System Event log … refer to service-specific error code 4″, or windows does not start the service, look in the event log (Admin Tools -> Event Viewer->System) and you’ll see the error from the Service Control Manager. The service-specific error is less than useful, but for me this meant that I did not get the path or the filename correct to the config file when I created the service.

4)If you specify different debugger ports for each CF instance, setup up a different debugger in your IDE for each CF instance, since one debugger can’t run on two ports (I would assume). This goes for anything else. If you configure different things in each JVM, you have to configure anything using the different instance settings to correspond.

Of course, if you don’t want to deal with all these services, and no server instances are running when you initally start windows, you can just start your cf server instance using the command line, with the -config option pointing to a custom config.

I think it is nice to have my 2 instances (soon 3 or 4), one for each dev environment, start up on their own when windows loads, each using a different port for a debugger. Too many instances running can really eat resources though.

Useful Links:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18206&sliceId=2

Coldfusion Scheduled Tasks, single quote in task name screws server up

The errors from accidentally putting a single quote somewhere in a scheduled task name in the CF Server Admin start like this:

Server (my local dev server) may start up and serve cfm pages, but error log has a bunch of errors.

The CFAdmin gives you a “The Cron service is not available” error

The server error log shows “error while reading header <VARIOUS HEADER NAMES HERE>”

The neo-cron.xml is invalid xml

Resolution: Since you can’t get back into CFAdmin, replace the neo-cron.xml with the default one (This will delete all your schedules tasks, but you can recreate them after the cfadmin works again). Or you can correct the syntax erro