CF: Meetup presentation about debugging materials (Nov 12, 2009)

Thanks again to everyone attending the presentation. The goal was to get an idea about debug space and think about attacking debug problems by first identifying what area they originate from. Hope this gave everyone to use.

Also we discussed with special focus on time based debugging from the performance perspective as well as from the perspective of handling time based exceptions predictevly.

Dowload presentation and code now.

Several questions regarding the use of CFDUMP came up and here are couple of links to deeper treatment of advanced CDFDUMP tag in CF9. Additinal attributes can be specified to tweak its behavior:

CFDUMP in CF9

Cheers
-Bilal

CF: CFinNC presentations

Hallo everyone. First thanks for attending my sessions. If you did not attend and wanted to take a peak at what we covered please feel free to review the slides. Of course more fun was had during the sessions ;o)

Download Beginning Debugging Session

Download Advanced Debugging Session

I have inlcluded more slides and examples than we covered hoping that they can be usefull as well. All my material are distributed under creative commons license. Feel free to contact me with questions or comments.

Generally, this conference showed that the spirit of CF is alive and well. It was an all volunteer event from the organization to the speakers and all the things in between. It introduced old and new people to CF and furthered networking in this Region. I hope we can make this an annual event.

Cheers,
-B.

CF: CFinNC is all about debugging for me

My presentations for CFinNC will be all about debugging. There is a lot to talk about crunched into two 50 minutes segments.
Debugging is the often hated but yet nonetheless very important part of the developer’s life fraught with lots of frustration and brief moments of glorious joy when the culprits are found. I am trying to give both the beginner and advanced audiences multiple techniques and tools to make the shining moments more frequent and frustrating times less so.

Here is my official description about the overall presentations:

Debugging can be a very frustrating exercise. Many times we find ourselves spending three times as long as it took us to develop the code to debug it. Especially code written by other developers seems time consuming to debug ;o)
Understanding the debugging infrastructure will shortcut much of the confusion and help to quickly focus on the source of the problem. What can you do when has reached is limits? We will talk about techniques, tools, and tips available to the ColdFusion Developer to make this a “less” frustrating exercise.

Hope to see you there,
B.

CF: CfinNC North Carolina ColdFusion / Flex / Air Conference – Oct 17-18, 2009

I will be presenting at the CFinNC conference this October. I will share some insight into working with SOLR, the search engine based on Apache Lucene as well as talk about debugging tips and tricks. If you have some insight you would like to share feel free to leave a comment.

CFinNC - Carolina ColdFusion / Flex / Air Conference - Oct 17-18, 2009

Here are the details on the conference:

Registration for CFinNC is now open! CFinNC is a free web development conference held in Raleigh, North Carolina during the weekend of October 17th and 18th with an International line-up of speakers presenting on timely and relevant topics on web development. Thanks to the generosity of our sponsors and the creativity of the planning committee, registration for the event will be free and includes entry to the weekend event and to all presentations.

In order to keep the event free we have removed some hard costs and some benefits you normally get from paid-registration events.

Please be aware of the following:

1) You are responsible for paying for lunch for both days. We have enlisted the services of a local caterer and will be providing lunch each day for $10/day. This includes a sandwich, chips and drink. Please bring cash the day of the event! We will not be able to process credit cards!

2) Limited Edition, Collectible CFinNC conference t-shirts will be available for purchase for $15 with any proceeds going to offset costs and possibly sponsor a planning committee dinner (if we sell them all).

Lunch and shirt purchase is completely optional. You may indicate if you would like to purchase lunch and/or a t-shirt on the registration form.

For more information, please check the CFinNC website at: http://www.cfinnc.com

-Cheers,
Bilal

CF: Adobe publishes hot fixes for ColdFusion

On August 17, 2009 Adobe published a number of security updates to numerous versions of ColdFusion. This has led to some scrambling to test these issues, get them patched etc.
So far the hotfixes did not appear to break anything but the packaging is lacking as many manual steps will have to be completed.
I could not quite understand why these hotfixes could not have been bundled together as one fix that can be applied.
To make our lives easier I have built an installer for ColdFusion 8.0.1 running on Windows systems to do just that. You are free to use it at your own risk.

The installer will update standalone installation of CF not J2EE/JEE installations.

Thus the following hot fixes will be applied:
CVE-2009-1872, CVE-2009-1875, CVE-2009-1876, CVE-2009-1877, CVE-2009-1878

These JRUN only updates will not:
CVE-2009-1873, CVE-2009-1874

Cheers,

Impressions from CFUnited, August 12 through 15, 2009

Many people in the middle of a Golf course. Learned new stuff, rehashed old stuff. The greats of ColdFusion held court, and Flex was the up and comer with attitude.
The good:

  • Open source coldfusion is engaged and attempting to move things forward. Adobe is cooperating for now. Railo was there and willing; OpenBD was there in spirit.
  • ColdFusion builder is here despite the CFEclipse and we can expect more opinions on why one is better than the other. Adobe did not want to play in this open source game.
  • ColdFusion 9 will have some expanded licensing options to make it easier to host things in the cloud.
  • ColdFusion has gained some momentum but still overall a nishe.
  • The food was pretty good.

The Bad:

  • Presenters could focus more on content and less on opinion.
  • Some are born to present; others not so.
  • ColdFusion is still niche and we need to not get so high on ourselves.
  • Flex purist insistance that they do not need to know anything about CF.
  • No CFUnited backpacks for the masses. What is up with that?
  • One hour barely covers anything technical well. More multi-hour tracks digging into topics would be helpfull for people seeking pure technology how to.

There is probably more that I missed but there you have it.

Cheers

CF: ColdFusion Serialization via Java API

This is a topic that has found many posts. Here is my spin ;o) Most of the posts focus on the success of serializing ColdFusion components. Though cool, many ask the same question: Why do this?
Also to note is that ColdFusion has supported a mechanism to serialize complex data via WDDX for a long time (I believe since version 4).
However, in my case, the need was not for serialization components but rather for compact serialization. In other words, use as little space (bytes/data) as possible. In addition, I needed to easily save and retrieve this information from a database in a text based format. Oh, yes, and handle complex data objects such as structures and arrays.
WDDX, though usable, is very verbose and thus was out. Looking at the Java API and reading through posts I translated this, in the end, to two functions fSerialize and fDeserialize. You will need ColdFusion 8.0.1 or higher to make this work.

The fSerialize function:


<cffunction name="fSerialize" access="public" returntype="string"
hint="uses java byte streams and Base64 encoding to serialize CF objects, this can be used instead of WDDX tag CFML2WDDX">

<cfargument name="input" type="any" required="Yes" hint="the CF object to be serialized">
<cfscript>

var objByteStream = createObject(
"java", "java.io.ByteArrayOutputStream").init();
var objOutStream = createObject(
"java", "java.io.ObjectOutputStream").init(objByteStream);
var objSerialized =
"";
//turn CF object in argument to out stream
objOutStream.writeObject(Arguments.input);
objOutStream.close();
//take outstream and make bytearray
objSerialized = objByteStream.toByteArray();
//encoded it and return

return BinaryEncode(objSerialized,"Base64");
</cfscript>
</cffunction>

fDeserialize function:


<cffunction name="fDeserialize" access="public" returntype="any"
hint="uses Base64 encoded Java Byte Array and turns to CF object. This can be used instead of WDDX WDDX2CFML">

<cfargument name="Input" type="string" required="Yes" hint="the Base64 encoded ByteArray that used to be a CF object to be deserialized">
<cfscript>

var objSerialized =BinaryDecode(Arguments.input,
"Base64");
var inByteStream = createObject(
"java", "java.io.ByteArrayInputStream").init(objSerialized);
var objInStream = createObject(
"java", "java.io.ObjectInputStream").init(inByteStream);
var objCF = objInStream.readObject();
//return the read object
return objCF;
</cfscript>
</cffunction>

These function on average were using 50% of the storage that a comparable serialized WDDX object would, so they achieved their objective for me. They will work on small components (cfc) but I have not tried to serialize very complex cfcs.

Cheers,
-Bilal

VSTS 2008: Database Load and Unit Test using Load Agents

There had to be a secret to this. Reading through the documentation, looking at examples, load testing with VSTS 2008 seemed a sophisticated affair, alas, only if you are working along the most popular path. More specifically only for web application testing.
I, being a renegade, wanted to use it to do Database Load testing. There are great new facilities in VSTS 2008 to create Database Unit tests but none speaks of how to do a load test.
I thought it would be easy enough to adapt the techniques in web-testing to database load testing. I found out I was very naive. I should have caught on when:
a) There was no documentation at all, no video, no web post, no nothing from MS or anyone having done this.
b) The number of errors I was getting when even trying to run it with one agent.

My test setup initially:
a) One workstation running controller and VSTS 2008
b) One server running VSTS Load Agent
c) A beefy SQL Server 2008 box to be load tested

Load testing on my workstation was working great, everthing was as expected and I was hopefull that this could easily translate into working well on the agent system. In short, it did not:

Here is the initial error I got:

  • System.IO.FileNotFoundException: Could not load file or assembly

I thought the deployment was enabled automatically, playing with the deployment option on the Test Run Configuration was not very helpfull. I ended up copying the assembly files into the same directories on the Load Agent, only to get errors referencing core related assemblies of VSTS2008. So, I created install project to deploy those… you guessed it, a wild goose chase in which I tried so many different things only to end up banging my head against a concrete wall. I nearly concluded that VSTS 2008 could not be used to do load testing for a database with Load Agents when an idea struck. This one ended up working, but could have been easily documented. So Microsoft peeps take it to heart …

I changed the test rig in this fashion:
a) Workstation with VSTS 2008 and controller + SP1
b) Server with VSTS 2008 and Load Agent + SP1
c) SQL Server 2008

The solution, thus, is to install visual studio team system 2008 on the agent computer/server as well, then install the agent. What good is an agent that does not cover all test cases? That is something that Microsoft hopefully will resolve. There seem to be dependencies on VSTS core files, I played with it a little. You do not need:

a) Any Crystal stuff
b) SQL Server Express
c) C++
d) dotfuscator stuff
e) Documentation or redistributables

My test where in C# so I installed on support for it and no other language.

Cheers,
Bilal

Java: Connecting to MS SQL server with JDBC and JRE 1.6

So,
I have this little Java project which requires that I connect to SQL Server 2005. Something I have done many times. Download the JDBC drivers from MS and copy them into the lib directory and do your shindig in the connection to get going.
But, this time things have changed and the installation instructions are worthless at best.

Here is what I did:

  1. Downloaded the driver files from MS for JDBC 2.0
  2. Unzipped to directory
  3. Moved jar files (there are two files sqljdbc.jar and sqljdbc4.jar) to my lib directory
  4. coded my connector to use Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”)
  5. Did some query code

And presto, nothing works as expected. Instead I get an exception with this in the stack trace:

“The JDBC Driver version 2.0 does not support JRE 1.4. You must upgrade JRE 1.4 to JRE 5.0 or later when using the JDBC Driver version 2.0. In some cases, you might need to recompile your application because it might not be compatible with JDK 5.0 or later. For more information, see the documentation on Sun Microsystems Web site”

Complete bogusness as neither Microsoft or Sun contain much info about how to solve this. So, head scratching starts followed by experimentation.

Come to find out I made a mistake by copying both jar files packaged in the driver to lib. They contain similar classes and the sqljdbc.jar files classes’ are used if both are copied. However, the sqljdbc.jar file classes are not ment to be used with jre/jvm 1.6+ . Why noone mention this in the provided install doc is a different question.

Solution:

a) Remove the not needed jar file (sqljdbc.jar) from lib directory or

b) specifically declare to use only the right one (sqljdbc4.jar)

Microsoft, please help us measly developers wasting time and state this in basic terms in your install doc.

There you have it.

Cheers,

CF: Unable to perform cfflush in cffunction

OK. This is not an obvious one, so I decided to document this behavior.
Say you have several functions in components processing away happily, and you want to give the user some feedback to keep him/her entertained as well as keep their paws of the back buttons etc..
You think doing couple of flushes during your processing may be a good way until you try and get this error:

Unable to perform cfflush.

You have called cfflush in an invalid location, such as inside a cfquery or cfthread or between a CFML custom tag start and end tag.

What to do? Since none of the hints apply to you. Your code looks like this:

<cffunction name="fFlushIt" hint="flushes current content">
<cfargument name="feedback" default="">

<cfoutput>#Arguments.feedback#</cfoutput>
<cfflush>
</cffunction>

<cffunction name="fProcessing" returntype="numeric"
hint="does processing" output="No">

<cfset var x=10>
<cfset var y=20>
<cfset fFlushIt("Processing Complete")>

<cfreturn x + y>
</cffunction>

<BR>
<cfoutput>The result is: #fProcessing()#</cfoutput>

here comes the digging into the code and making guesses part. It seems that there is one more scenario cfflush won’t like and this is if you call in within a call-tree (yes even nested stuff) in a function that has the output attribute declared as “No”. Maybe a hint like that could be placed in the error to avoid all that brain scratching and wondering that goes along with this?
Anyways change the function like this and it worked. Yeah !


<cffunction name="fProcessing" returntype="numeric"
hint="does processing" output="Yes">

Cheers,