Apache Ninja Crash Course for Developers - cf.Objective() 2013 - Slides Online

The slides for my cf.Objective() 2013 presentation are now online:

Apache Ninja Crash Course for Developers

Thank you to all who attended!

ColdFusion Developer Week 2012

Adobe's second ColdFusion Developer Week kicks off today, June 4, and continues through Friday, June 8, 2012. Whether you're a new or experienced CFML developer, there's probably more than one session you'll find very interesting and useful. From basics to advanced language features, as well as frameworks and a focus on the new ColdFusion 10 release, there's just loads of good stuff, all provided via free online Webinars.

Check out the sessions and schedule, and sign up.

Like last year, I'll be presenting Improve Your Apps Through Unit Testing, tomorrow.

I also hope to revive this sleepy blog with some more interesting tid-bits soon, so stay tuned! It's been a busy year, but I've queued a number of topics for blog posts, so hopefully I can catch up a little in the near future.

Go To OpenCF Summit!

I've been meaning to post about OpenCF Summit for a few weeks. If you haven't already heard about it OpenCF Summit, it's home page describes is as follows:

OpenCF Summit is a community gathering focused exclusively on advancing free and open source software in the CFML community.

If you're interested in diving into the free software CFML engines, learning more about the free software movement, and interacting with the most progressive thinkers in the CFML community, OpenCF Summit is for you!

A couple recent blog posts finally prompted me to write up this post...

First, Bob Silverberg recently posted Why Contribute to Open Source Projects? If you've ever wondered about the answer to this question, or if you just haven't had time to participate or learn more about open source software projects, I highly recommend reading Bob's post! It gets my +1 all around--I wholeheartedly agree on all points, and I can't think of anything he's left out.

Second, as if the OpenCF Summit registration wasn't already incredibly reasonably priced, it was just lowered to $30--it's a steal! From the beginning, the OpenCF Summit organizers have aimed to keep costs down, and they've really delivered. I'll highlight a few quick thoughts about why I'm super excited to be attending and speaking at OpenCF Summit, but I also encourage you to check out the OpenCF Summit blog, which contains numerous posts about what the conference is all about, what it has to offer, and how you can participate and enjoy.

For all of the reasons outlined by Bob, I'm quite passionate about open source software, and I truly enjoy participating--be it bug reports, coding, documentation or just good forum discussions. For all that makes technology conferences awesome (great opportunities for learning, sharing, networking, and just having a great time with great people), I'm passionate about attending whenever I can. So, when I first heard about OpenCF Summit, it sounded like a geek's dream come true :P I planned to attend, without question.

To make things even more exciting, I submitted a topic to present, and I'm honored to have had it accepted: Complete FOSS CFML Development Stack. I just think it's fantastic that we, as CFML developers, have the option to develop on a completely free and open source software stack--from operating system to version control system! Better yet, there are numerous options in every category (operating system, Web server, application server, CFML engine, database engine, IDE, VCS, etc.). I've been developing with Ubuntu as my primary desktop operating system for well over two years now, and I love it, so I'm very excited to share my experience.

To be clear, I haven't been strictly FOSS only, but in the spirit of the conference, I thought this might be a nice topic, because you can be a strictly FOSS CFML developer, should you choose. As great as CFEclipse is (and Eclipse, in general), there's no Flex support for Linux. On the commercial side, as great as ColdFusion Builder sounds, there's no Linux support. I've been using IntelliJ IDEA as my primary IDE for a while now, because it's a fantastic IDE, in general, and it supports CFML, Flex and Groovy development very well. While there is a free and open source version of IntelliJ (Community Edition), the non-free commercial Ultimate Edition is required for CFML and Flex support. It's very reasonably priced and pays for itself in development efficiency almost immediately. That said, I still like to support CFEclipse and use it on a number of personal projects. As for CFML engines, I'm a huge advocate of the CFML development community, and I like to spread the love ;-) I enjoy the best of Adobe ColdFusion, OpenBD and Railo whenever I have the chance!

You Too, Should Attend OpenCF Summit!

Why? Well, as I've mentioned, it's a whole lot of fun to attend conferences, and the amount you'll learn from conference sessions, unconference sessions, hallway conversations, dinner and after-hours conversations, is just incredible. That much holds true for just about any decent conference, and considering the large number of incredibly smart, kind and generous folks involved in OpenCF Summit, it's a no-brainer. If you're at all new or curious about the many wonderful open source projects in the CFML community, this is the best place in the world to learn more and get involved right now. If you're already a big fan of open source and CFML, well, this is basically a Disney World trip for the OSS geek in you.

There's a great looking schedule. There's a great group of speakers, and I know of many great attendees that will be fun to converse with too. There's a great group of partners sponsoring the event. There's a community hackfest planned, an unconference room, Pecha Kucha and BOFs.

How about networking? Are you looking for more professional connections? Is your company looking for another qualified team member? This is the place to be! I, for one, am looking to hire a couple passionate programmers right now, so if you're looking for a great opportunity, find me at the conference! (Or, better yet, contact me now.)

And if all the usual conference goodness and a great group of people isn't enough to get you psyched, read up on the OpenCF Summit blog posts for other exciting stuff. So, come and join the fun in Texas, Feb 21-23. I hope to see you there.

Railo Access DSN on 64-bit Windows

I just wanted to post a quick note about this, as it was not the least bit obvious. I was helping to configure an old CFML application, which used an MS Access database, on a Windows Server 2008 RC2 (64-bit)/Apache 2.2/Tomcat 7/Railo 3.1 setup. This was being migrated from a 32-bit Windows server to a 64-bit Windows server.

Before I continue, let me first make a few suggestions. If you're building a new CFML application, I'd first recommend deploying (or at least coding to allow for deploying) to a Linux server using either MySQL or PostgreSQL databases. Linux servers are stable, secure, fast and cheap. MySQL and PostgreSQL databases can be used on just about any platform. If you prefer Windows servers (or have no choice), I'd still suggest MySQL or PostgreSQL databases, as they could be easily migrated to Linux in the future (Apache HTTPD also runs great on just about any OS). If you prefer to use (or must use) a Microsoft database, use SQL Server--not Access. There's an Express edition available, which is much more suited for a Web application database than Access, and there is much better 64-bit driver support.

Okay, so if you must go with an Access database on 64-bit Windows, the problem with using an Access database for a CFML application on a 64-bit Windows server... On 32-bit Windows it's quite simple to connect Railo to an Access database: use the Windows ODBC Admin to create a System DSN that points to your Access database file, and then create a Railo data source using the JDBC-ODBC bridge option. Unfortunately, on Windows Server 2008 64-bit, the ODBC Admin does not even show an Access driver option. If you Google around for a solution, you'll be tempted (as I was) to use the "secret" 32-bit ODBC Admin tool, which is located at %systemdrive%\Windows\SysWOW64\odbcad32.exe (the default 64-bit admin is at %systemdrive%\Windows\System32\odbcad32.exe--yes, Microsoft put the 32-bit tool under a directory containing "64" and the 64-bit admin under a directory containing "32" and both file names contain a "32"--nice). If you use this admin tool, you'll be able to create a System DSN for your Access database using a 32-bit driver, however, it will not work with the JDBC-ODBC bridge, because Railo/Tomcat a 64-bit application (running on a 64-bit JVM).

Finally I discovered that Microsoft has finally released 64-bit ODBC driver support, so the real solution is... Go here and download and run the AccessDatabaseEngine_X64.exe installer on your 64-bit Windows server. Now you can simply open the usual 64-bit DSN/ODBC admin tool (under Administrative Tools, I believe) and create a System DSN for your Access database (a driver is actually available there now). The Railo JDBC-ODBC bridge datasource type will now work.

CFML on Tomcat via Apache AJP Proxy, Redux

I often use Tomcat as my servlet container to power my CFML apps (works great for ColdFusion, Open BlueDragon and Railo!). I've been perfectly happy with the power and flexibility of using Apache HTTPD's mod_rewrite with an AJP proxy, as Sean Corfield has detailed. Then, after repeating a lot of rewrite rules in all of my virtual host definitions, I decided to merely place the following in my main Apache configuration file:

<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2

That's it! Now, any Apache virtual hosts for CFML application can be defined as simple as this:

<VirtualHost *:80>
ServerName myrockinapp
DocumentRoot /var/www/myrockinapp
DirectoryIndex index.cfm
</VirtualHost>

I can still easily add URL rewriting to my Apache virtual hosts. For example, when using Mura CMS I often set the properties siteIdInURLs=0 and indexFileInURLs=0 to make super clean looking URLs (with no siteID or index.cfm in the URLs). This then of course requires a rewrite rule to ensure the proper requests are passed to Tomcat, which is as simple as adding these lines to your virtual host (or an .htaccess file in your Web root):

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^([a-zA-Z0-9/-]+)$ /index.cfm%{REQUEST_URI} [PT]

Makes all the configuration I used in this post look a bit silly now :P

Also, if you're interested in a clean, production-worthy server setup running on Ubuntu 10.04 with Railo, Tomcat, Apache and MySQL, I have this fairly well documented in this Google Doc.

Git Global Ignores, Can Be Overridden

First off, I'm loving Git (fast/awesome/free/open-source distributed version control system). If you haven't already, check it out!

I'd like to briefly mention how to ignore certain files from version control, both by project and globally. I'd also like to confirm that it's very easy to add files to version control, which are normally globally ignored.

Git makes it simple to ignore certain files/directories/patterns from version control by creating a .gitignore file in your project root, and optionally in any sub-directory. Check out the gitignore docs page for more.

That said, I quickly found myself ignoring the same patterns for every repository. Fortunately, Git also makes it easy to globally ignore patterns. You just set a global config property of core.excludesfile to tell Git where to look for a global gitignore file. The following two commands take care of setting the property and creating a file with a few popular ignore patterns.

git config --global core.excludesfile ~/.gitignore
printf ".project\n*.iml\n.idea/\nWEB-INF/\n" >
> ~/.gitignore

The above commands will work on both Linux and Mac. Windows users will likely want to locate a global .gitignore file in some common user settings directory. You can then create/edit the text file any way you'd like.

For me, on Ubuntu Linux, I end up with a /home/jkrug/.gitignore file that looks like this:

.project
*.iml
.idea/
WEB-INF/

You can also manually edit your .gitignore file, of course, and add comments if you'd like:

# Eclipse project files
.project

# IntelliJ IDEA project files
*.iml
.idea/

# Java WAR directories
WEB-INF/

Now here's the bonus: if you have one repository in which you'd like to add a file that is globally ignored to version control, you can do so. Simply use a standard add command with a -f flag, e.g.,

git add -f WEB-INF/web.xml

The global ignores are especially useful to me when I fork a project that may not have an ignore for my primary IDE's (IntelliJ IDEA) configuration files. And when I have a custom project in which I'd like to add one of those global ignores--no problem!

Happy versioned coding :)

cf.Objective() 2010: Intro to JEE Servlet Containers for ColdFusion Developers

Note: this has also been translated to Spanish, here.

I am thrilled and honored to have the opportunity to speak at this year's cf.Objective() 2010 conference! My session title is "Intro to JEE Servlet Containers for ColdFusion Developers" and here is the preliminary description I used when submitting my session topic:

An alternate title for this session might be, "What the heck is a servlet container and what does it have to do with CFML?" We'll discuss the relationship between CFML "engines" (i.e., servlets), JEE application servers and servlet containers, and Web servers. Understanding the basics of this relationship can provide CFML developers with a greater confidence to leverage underlying Java tools, improve development environments and deployments and write more flexible and powerful applications.

Why Bother?

I submitted this topic because I believe there are many CF developers, of all skill levels, with very little knowledge in this area. I was most certainly one of these developers for the better part of my CF career thus far! Over the past year or two I've developed a much deeper understanding of Java Enterprise Edition (JEE/J2EE), Servlets, Servlet Containers, Java Application Servers and Web servers. Most importantly I've learned a lot more about how Adobe ColdFusion, Open BlueDragon and Railo leverage the power of these Java platform specifications.

Much of my learning has been out of necessity -- and I feel like I had to do it the hard way (on my own)! But looking back, had I possessed some base knowledge in the right areas, I really think I may have put all the puzzle pieces together much more quickly. So I'm hoping to provide these building blocks in my cf.Objective() session this year.

You don't need to become a Java guru to grok these concepts, but they can greatly increase your toolset as a ColdFusion developer, allowing you to design and develop more robust applications and gain greater marketability in the job market. Here are some points that I hope to provide attendees:

  • 10,000-foot view of how CFML Engines, Servlet Containers, Java Applications Servers and Web Servers interact to make the magic we've all come to know and love
  • Understanding the many options the Adobe ColdFusion installer provides and what you can (and might want to) do on your own
  • Confidence and flexibility in CF development environments (application isolation, starting app servers from your IDE, super-simple portability, etc.)
  • Configuration options to keep both development and production environments running smoothly
  • Understanding and leveraging EAR/WAR deployments
  • Awareness of the many options and not being afraid to check them out!

Lots to talk about, feedback needed!

As you can imagine, there is a lot that can be covered here. My goal for this session is to provide an understanding of the important pieces of the big picture, tools you can put to immediate use, and a confidence to safely explore more deeply. If any of the concepts or buzz words I've mentioned in this post are scary, please know that they're not -- not if you start in the right place.

If you feel any one area or concept that I've mentioned would be of greatest value to you... If you have a more specific question that keeps coming up, or something that you continue to avoid... If you know this stuff cold, but see common problem points out in the CFML community... I would highly value your feedback as I continue to refine my session preparation. Please comment on this blog post or use my contact form to contact me directly.

Whether you're already grokking some or none of what I've discussed here, I hope you can make it to my cf.Objective() session and take away some useful bits!

Bash Script to Set Sensible Directory/File Permissions

Every once in a while a directory structure's permissions just get messy (or an archive I download and extract has stupid permissions, like making every single file executable). So I'll occasionally want to chmod 755 all directories and chmod 644 all files. If you're new to file system permissions in Linux, let me translate that goal. For every directory I want the owner to be able to read/write/execute (execute allows to cd into directory) and both group and all others to have read/execute permissions. For every file I want the owner to have read/write permissions and both the group and all others to have read-only permission. The Ubuntu Community Documentation has a good File Permissions page that covers this in more detail.

That same documentation has a Recursive chmod using find, pipemill, and sudo section that details precisely the two commands I need, but I hate to waste time finding this link and carefully remembering what I want to do. So, I've whipped up a simple Bash script that simply accepts a directory path as its only parameter and prompts me to confirm before making the permission changes. Here it is.

#!/bin/bash

# exit this bash script if any statement returns a non-true return value (same as: set -e)
set -o errexit

if [ -z "$1" ]; then
    echo
    echo "ERROR: Must pass parameter of path to directory (which will have permissions set accordingly; 755 directories and 644 files)."
    echo "USAGE: $0 /path/to/directory"
    echo
    exit 1
fi

echo
echo "Working recursively with directory $1 this script will chmod 755 all directories and chmod 644 all files."

read -p "Okay to continue (y/n)? "
if [ "$REPLY" != "y" ]; then
    echo
    echo "EXITING -- NO ACTION TAKEN."
    echo
    exit 1
fi

echo
echo "Starting..."
echo

find "$1" -type d -print0 | xargs -0 chmod 755
find "$1" -type f -print0 | xargs -0 chmod 644

echo "Done."
echo

exit 0

Since I'll often need to run this script as root, I've taken a few extra steps to protect it by making it owned and executable only by root:

sudo chown root:root setperms.sh
sudo chmod 744 setperms.sh

So, from the directory containing this script (as you can see I've named mine setperms.sh), here's an example usage:

sudo ./setperms.sh ~/directory-to-clean-up-permissions

If your directory has strange owners and/or groups set, you can quickly clean that up recursively as well. For example:

sudo chown -R jkrug:jkrug ~/directory-to-clean-up-permissions

SvnAnt Task/Type Definition Import

I'm finally getting wise and leveraging ANT more, and yesterday was my first attempt at integrating some Subversion tasks. I discovered SvnAnt rather quickly, but didn't have a good sense for the best way to leverage it. Marc Esher kindly helped with a response to my comment here.

Rather than repeating a bunch of path/fileset/typedef lines in every build file that requires SVN tasks, I decided to create a simple build file that would handle this type definition and allow me to place just one import line into each build file that requires SVN tasks.

To start, I downloaded the proper SvnAnt distribution (from here), unzipped the folder under my /opt directory (I'm running Ubuntu), and created a symbolic link to the folder so I can reference it as /opt/svnant.

Then, under my /opt/svnant folder I created a build file called svnant-typedef.xml with the following:

<!--
    This build file serves to map SvnAnt's task and type names to their implementing classes.
    This file should be located in the SvnAnt distribution folder root (parent directory of /lib).
    It can be imported to any build file, rather than repeating, for example:
    <import file="/opt/svnant/svnant-typedef.xml" />
-->

<project name="svnant-typedef" basedir=".">

    <!-- get directory of current build file -->
    <dirname property="svnant.basedir" file="${ant.file.svnant-typedef}" />

    <!-- file set for SVNAnt classpath reference -->
    <path id="svnant.classpath">
        <fileset dir="${svnant.basedir}/lib">
            <include name="*.jar" />
        </fileset>
    </path>

    <!-- task/type definitions for SVNAnt library -->
    <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />

</project>

You can read about the ANT import task and its special properties here.

Now I need only import the above file in build file's that will use SVN tasks. Here's an example:

<project name="example" default="main" basedir=".">

    <import file="/opt/svnant/svnant-typedef.xml" />

    <target name="main">
        <svn svnkit="true" javahl="false">
            <export srcurl="file:///home/svn/example/trunk" destpath="/tmp/example" />
        </svn>
    </target>

</project>

Apache Authentication with Proxy

I've enjoyed leveraging Apache mod_rewrite and mod_proxy to leverage both the power of URL rewriting and the APJ proxy to proxy CFML requests to Railo running on Tomcat. I allow Apache to still handle requests for static assets (images, javascript, etc.). Today, I ran into a problem when I wanted to slap some basic authentication on a site. Requests handled entirely by Apache (static assets) were challenged for authentication, but CFML requests were proxied to Tomcat without requiring authentication. It makes perfect sense, as did the solution once I found it, but it just didn't occur to me at first.

First, here's a quick example of a basic virtual host that I'd use:

<VirtualHost *:80>
    ServerName mysite
    DocumentRoot /var/www/mysite/webroot/
    DirectoryIndex index.cfm

    <Proxy *>
        Allow from 127.0.0.1
    </Proxy>

    ProxyPreserveHost On
    ProxyPassReverse / ajp://mysite:8009/

    RewriteEngine On

    RewriteRule ^(.+\.cf[cm])(/.*)?$ ajp://%{HTTP_HOST}:8009$1$2 [P]
</VirtualHost>

After creating a password file using the htpasswd command, I thought I'd simply add the following inside my VirtualHost to provide basic authentication.

<Directory /var/www/mysite/webroot/>
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /usr/local/etc/apache/mysite.passwd
    Require user someusername
</Directory>

Unfortunately, as I mentioned, this only protected non-proxied requests. Fortunately, I found the tip for my solution relatively quickly at stackoverflow, here. I simply needed to apply the same authentication directives within the Proxy context.

Here's the revised virtual host with basic authentication for both static assets and those proxied to Tomcat:

<VirtualHost *:80>
    ServerName mysite
    DocumentRoot /var/www/mysite/webroot/
    DirectoryIndex index.cfm

    <Directory /var/www/mysite/webroot/>
        AuthType Basic
        AuthName "Restricted Files"
        AuthUserFile /usr/local/etc/apache/mysite.passwd
        Require user someusername
    </Directory>

    <Proxy *>
        Allow from 127.0.0.1
        AuthType Basic
        AuthName "Restricted Files"
        AuthUserFile /usr/local/etc/apache/mysite.passwd
        Require user someusername
    </Proxy>

    ProxyPreserveHost On
    ProxyPassReverse / ajp://mysite:8009/

    RewriteEngine On

    RewriteRule ^(.+\.cf[cm])(/.*)?$ ajp://%{HTTP_HOST}:8009$1$2 [P]
</VirtualHost>

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.2.002. Contact Blog Owner