Monday, December 31, 2007

Thursday, December 27, 2007

Liquid XML Studio is awesome!

I have been working on an XML file for the http://www.bahaullah.org site (see the post below). Anyway, after creating and editing it in Dreamweaver CS3, it worked fine parsing it using XMLParse (in ColdFusion). However after editing the exact same file in Microsoft XML Notepad, XMLParse crashed -- apparently XML Notepad added some additional hidden characters at the beginning of the xml file (that could only be seen with VI).

Anyway, after some digging to find a better XML editor that wouldn't cost a lot (XML Spy is $500 and oXygen is $200+) I found Liquid XML Studio. It's a great program and has a free version. Very easy to use and you can't beat the price! I was able to create an xml schema and validate the original doc in about an hour (with a little help from online tutorials).

Getting to this point has cause a LOT of headaches but it was worth the trip. Now others will be able to edit the doc and validate it without paying a penny for an editor...

Check it out>

Wednesday, December 26, 2007

Coldfusion caches IP addresses -- so watch out when you change DNS!

Since one of the purposes of this blog is to keep track of bugs for future reference, here was one that caused no end of grief.

1. Some time ago we built an admin tool that used an CFHTTP tag to retrieve a .cfm page and then save the resulting .html to the server. This allowed us to flatten the .cfm pages for serving through Apache. (BTW--This lowered our use of Coldfusion to a minimum and improved our server stability dramatically).
2. Some time later we moved our sites to a new server and had to change DNS to reflect the new IP address of the box.
3. The admin tool was only used sporadically so the next time we used it none of pages would save new content. All of a sudden our admin tool wouldn't work at all!
4. As luck would have it we remembered that we had changed the IP address a week or so before and after some debugging found that CF was still going to the old IP to build the files.
5. Thanks to Google we found some posts that documented that CF caches DNS entries internally so in order to fix the problem you need to restart CF!

Here is one post that explains it (from here):

I just ran across this issue again, CFHTTP requests to a hostname work from one Coldfusion server but not from another. The JVM caches hostname-to-IP address resolution for infinity, by default. This means that if you have a local DNS server with a host name mytest.mydomain.com and it is set to resolve to 127.0.0.1 each CFHTTP request (or CFFTP, CFLDAP, CFINVOKE) to mytest.mydomain.com after the first call will resolve to the IP 127.0.0.1. If you change the DNS entry at some point to resolve to a different IP, Coldfusion never picks up on this change, but instead continues to try and resolve to the old IP address, unless you restart Coldfusion.

You can change the caching policy by editing the networkaddress.cache.ttl value in the cf_root\runtime\jre\lib\security\java.security config file.

In the cool category

Adobe is now in the Beta phase for "Share" -- a Flex-based sharing program. It appears that Adobe is really going strong in the collaboration tools arena and between this and Brio -- more about that later -- they are making some great moves. Anyway, you can store and share up to 1GB for free and even add a preview to the file in other Web pages like this:

Subversion conflicts

Another problem I ran into today was when I tried to revert to an old version of my xml from Subversion. But Subversion kept complaining that were conflicts between my own versions of the file -- but no one else had edited the file except for me!

The worst part is that the issue went away without my knowing exactly what solved it.....

....I hate that!

Cold Fusion not parsing xml \ Dreamweaver adding characters

This is the primary reason I started this blog. I had dealt with this issue before but since I didn't write it down someplace I had to figure it out all over again.

If you have an xml file that you edit and upload to a server, there are cases where hidden characters will prevent the code from being parsed using the XMLParse() method. It seems that some editors will place hidden characters in the beginning of the xml -- i think its because the encoding is incorrect. The xml will look fine in Dreamweaver and even notepad but will crash and burn in some parsers. For instance I had done the xml for www.bahaullah.org and stored it on a server. I then did:

XMLContent = ToString(trim(cfhttp.filecontent));
XMLContent = XMLParse(XMLContent);


and instead of parsing the xml it threw this error:

An error occured while Parsing an XML document. Content is not allowed in prolog

To fix it I had to edit the file directly on the server using vi and removed the characters that appears just before the opening root node.

AND then it appears that the errors can also be introduced in Dreamweaver CS3 for .cfm files too!! While I was trying to modify a .cfm file and change the path to the file, it apparently added odd characters along with the "_" -- even if I tried to remove the "_" again.

I also had to fix this by editing the .cfm file using vi in unix.

This is very frustrating as I have spent hours debugging errors that I can't even see...

UPDATE-- It's a short time later but I just found the main gremlin. I had also tried opening the file in Microsoft XML Notepad 2007 and this is what added the special characters! I should have known that it would be caused by Microsoft and not Adobe Dreamweaver ;-)

Although I'm still not sure what caused the issue with the config.cfm edit too -- but i'm sure it CAN'T be adobe!

First post

My wife and I have had a personal blog for a few years now but it seems to be a bad place to put technology notes and so on. So this one is really designed for personal notes to myself, coding hacks, cool web sites and so on (things that are too verbose to fit on Ma.nolia.

Since its not designed for anyone else than me, if you happen on this by accident, accept my apologies -- it will probably be like opening up somebody else's closet just to find the stuff they hid before you arrived ;-)