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!
The slides for my cf.Objective() 2013 presentation are now online:
Apache Ninja Crash Course for Developers
Thank you to all who attended!
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.
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!
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.
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:
That's it! Now, any Apache virtual hosts for CFML application can be defined as simple as this:
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):
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.
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.
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:
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!
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:
After creating a password file using the htpasswd command, I thought I'd simply add the following inside my VirtualHost to provide basic authentication.
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:
There's lots of chatter about CFC creation performance in the popular CFML engines (Adobe ColdFusion, Open BlueDragon and Railo), and plenty of others have ran their own tests, but I'm just curious and had to see some tests for myself.
I do not intend to encourage anyone to choose any one engine over another solely based on these tests. This is just one small indicator of the many performance considerations! In a real world application, there are many other performance considerations (hardware, operating system, application server, JVM tuning, CFML engine admin settings, various cache mechanisms, database server, database tuning, etc.).
I'm just focused on the speed of CFC creation here. In many small or medium sized apps, this is not much of a factor, but in larger applications where large sets of objects need to be created, this can potentially become crippling to application performance.
Also keep in mind that not all CFML applications are guaranteed or even likely to migrate flawlessly between any two CFML engines, despite lots of great progress towards compatibility and a core CFML spec. There are also lots of vendor specific features that may sway a particular developer or team to a particular CFML engine, and this may vary from project to project.
I could ramble on with more disclaimers, but let's get to the good stuff!
A (very) brief list of ColdFusion/CFML resource links in response to Tweet from @ryanmaurodesign: "Does anyone have an opinion on Adobe Coldfusion?"
The short answer: yes :) There is a vibrant CFML community and many will be excited to tell you why it's so fantastic!
Adobe ColdFusion Evangelism Kit
Other major (open source and free) CFML engines:
Open BlueDragon
Railo
ColdFusion is a Java EE application... http://en.wikipedia.org/wiki/Coldfusion#ColdFusion_and_Java
Just a few of the very many busy bloggers:
Ben Forta
Ben Nadel
Charlie Arehart
Hal Helms
Ray Camden
Sean Corfield
...and a bunch more ;-)
http://coldfusionbloggers.org/
A bunch of open source ColdFusion apps (as well as other Adobe RIA related stuff):
RIAForge
Popular MVC frameworks (there are more):
ColdBox
Fusebox
Mach-II
Model-Glue
Other popular frameworks (there are more):
ColdSpring ("Spring framework for ColdFusion")
Reactor (ORM)
Transfer ORM
There's a ton of other great information out there, so go check it out! (Ignore the occasional/ignorant "ColdFusion is dead" nonsense that somehow still creeps up from time to time, despite continued growth!:)
I've discovered a bit of a bug in the way Mura CMS handles 404s and wanted to share my workaround. Valid path_info for Mura pages consist of only letters, numbers, hyphens and forward slashes. If you browse to a path that doesn't exists, Mura properly throws a 404 error -- well, sometimes...
If it's a valid Mura formatted URL, you'll get a 404. For example:
http://www.getmura.com/index.cfm/i-do-not-exist/
...however, if the path_info is not "valid," Mura seems to ignore it and display the home page -- for example:
http://www.getmura.com/index.cfm/i-do-not-exist.html
On some sites, you might not care about this, but Google and other spiders can become very suspicious when non-existent URLs return a 200 response instead of a 404. I discovered this when our SEO/content guru was having trouble getting Google Webmaster tools to verify after I uploaded the specified uniquely-named html file. Google refused to authenticate us, because they were attempting to "test" for a 404 and instead got 200 responses. I assume they just make up a random file name or path and expect a 404. It makes sense that they want to ensure that the site doesn't return a 200 OK for everything, because they can not count on the 200 from the authenticity file/URL to be true.
You can leverage URL rewriting as one workaround, as I have. Based on the standard default site URL format of Mura CMS, you can use something like the following with Apache mod_rewrite to force a Mura 404 when an "invalid" path_info exists:
UPDATE, 8/31/2010: I'm going with a simplified approach these days, as posted here.
I've worked with Apache mod_rewrite quite a bit in the past, but never got into any terribly complex rewrite rules. On average, I've probably leveraged about 2% of the incredible potential power that mod_rewrite offers. More recently I finally had the opportunity to learn a bit more and leverage this handy tool. My rewrite rules evolved over the past couple months as I got into testing out the Railo CFML engine a bit more, and then while setting up my first Mura CMS powered site. I thought I'd share what I've learned, as others may be likely to use some or all of this type of Apache virtual host configuration.
Here's a run-down of the "end goal," if you will, which I will walk through step by step to recap the problems and solutions I discovered along the way:
Please note that the following Apache modules must be activated in your Apache configuration: mod_rewrite, mod_proxy and mod_proxy_ajp.
I'll simply direct you to existing resources for this first bit and then show my basic example virtual hosting configuration. First, I'm running Railo in a multi-web setup on a single instance of Tomcat, which Sean Corfield has nicely outlined here (including a kind nod to a prior blog post of mine :). I learned a very nice means of proxying CFML requests from Apache to Tomcat thanks to this Sean Corfield post, which was prompted by some helpful comments from Barney Boisvert on Sean's prior post.
So here is an example Apache virtual host:
Okay, the above gets Apache proxying standard *.cfm/*.cfc requests to Tomcat for Railo to handle, but a request to http://railocmstest/index.cfm/some-path-info/ will simply throw a 404 error, because Apache finds neither file nor directory at /var/www/railocmstest/webroot/index.cfm/some-path-info/. Plus, the current rewrite rule is not even proxying this type of request to Tomcat, because the regular expression used only looks for any URI that ends with ".cfc" or ".cfm".
Simply change this line:
...to this:
Okay, now if we reload Apache the http://railocmstest/index.cfm/some-path-info/ will indeed be proxied to Tomcat, however, now we just get the 404 error from Tomcat instead of Apache! Not a problem -- I picked up another trick from a comment by Tony Garcia on, again, this Sean Corfield post. In either our Tomcat's conf/server.xml file or in our Web root's WEB-INF/web.xml (you can create one if it doesn't exist) file, add the following servlet mapping:
Just be sure the servlet name you use here matches the one used for Railo, which is CFMLServlet by default, but I change mine to GlobalCFMLServlet in my multi-web setup as explained here.
We can now restart our Tomcat service and http://railocmstest/index.cfm/some-path-info/ is now good to go -- no more 404 error and cgi.path_info will now properly return /some-path-info/.
You may be inclined to try a URL pattern of /*.cfm/* in your servlet mapping, as I was, but it will not work as expected. If you also need URLs ending with /other.cfm/path-info/ and /app/index.cfm/path-info/, for example, you'll have to add two more servlet mappings with URL patterns /other.cfm/* and /app/index.cfm/*.
A simple way to hide your Railo Admin URLs is to use one rewrite rule to forbid access to any paths beginning with /railo-context/admin/ and use some unusual URL to proxy in its place:
After an Apache reload, the above rewrite rules will cause a 403 (Forbidden) error to be thrown at http://railocmstest/railo-context/admin/index.cfm, but you can find what you're looking for at http://railocmstest/SOMETHING-DIFFICULT-TO-GUESS/admin/index.cfm with no problem. In this Railo Google Groop thread Sean Corfield also suggests using a separate virtual host to access your admin, which can listen on an unusual port. You could also use SSL to encrypt transmissions at the admin URLs.
"Out of the box," Mura CMS has relatively friendly, SES URLs of the form http://host/siteid/index.cfm/something-friendly/, but we can do better. In the helpful Mura forums I quickly found the information I needed to make very quick changes to the Mura code to get rid of the /siteid/index.cfm portion of the URLs generated. Since there were two steps, in two different threads, plus one other tweak I found necessary, I posted a summary thread to a Mura forum. The rewrite rule example I provide in the form thread is more generic, intended to work without consideration for Tomcat proxying, Railo Admin hiding, etc., so here's what I've actually done for my first Mura CMS powered site...
I found that I needed to cover a few extra use cases. These four situations must be covered:
...and here it is:
If you're wondering why I have rewrite conditions with %{DOCUMENT_ROOT}%{REQUEST_URI} instead of %{REQUEST_FILENAME} when checking for file/directory existence, it's because the latter just didn't work for me! All examples I've seen suggest the latter, but it just didn't work -- possibly something Ubuntu-specific, or something that I changed elsewhere in my Apache configuration? I don't know, but what I've used should work on any setup.
I've discovered a little bug in Mura CMS regarding the handling of would-be 404 pages, so the last two rewrite rules from above must be changed to be less broad and an additional final rule can be added to still leverage the friendly/skinned Mura 404 page (rather than Apache's default 404):
I've also updated the following Complete Package section to reflect these updates...
So, here is the complete virtual host example, incorporating all of the above:
Cheers!