January 29, 2003

Flash Remoting & PHP

A fascinating development of late has been the appearance of some PHP code that allows you to use Flash Remoting with PHP. You can read the initial flurry of discussions on Flash Database's forum. There's explanations of the machinery and links to the code. I downloaded it and, after several subtle problems, got it working. Things to watch out for: when you download the PHP code, make sure you have no rogue whitespace characters in the files (either illegal whitespace inside the <? ... ?> or any whitespace outside the <? ... ?>). The original code from "musicman" handles byte ordering and works on both Mac and Windows. The current code on SourceForge is Windows only because it does not handle byte ordering correctly.

p.s. I'm still bummed that Safari doesn't support Flash Remoting.

Posted by seancorfield at 08:28 PM | Comments (0) | TrackBack | mx | php

January 28, 2003

A bit off?

One of the most common programming errors in the world is the notorious "off by one" error. It manifests in several ways but the essence is that code runs one past some boundary condition. I've seen a couple of examples of this on cf-talk lately, usually in the context of people trying to add elements to arrays. I've looked at the code fragments people post but I can't quite put my finger on why this causes many ColdFusion programmers such trouble. I wish I could, because then I could offer some simple advice on how to avoid the problem. The best I can say is: do a walk through of your code for a couple of different cases, usually 'no elements' (initial run), 'one element' (second run) and for some arbitrary number (e.g., 10). Use a pen and paper. Down the left side of the page, write each variable name. As you step through the code manually, cross out each variable's prior value and write in the new one. This might seem primitive in this modern, high-tech world but it really does help you focus on exactly what the code is doing.

Of course, my personal preference would be to run a code analyzer over the code that can deduce code invariants and prove transformations on the data. Except we don't have such a thing for ColdFusion. I've worked on tools like that for other languages in the past but such tools are extremely hard to create and often require a language subset in order to be effective. Meanwhile, it's pen and paper...

Posted by seancorfield at 07:24 PM | Comments (1) | TrackBack | programming

Busy Ken...

After a month-long hiatus, Ken Bereskin's web log has shown some activity again. I'd gotten a bit worried about the lack of activity and I'd been missing my near daily Mac tidbits!

Posted by seancorfield at 06:49 PM | Comments (0) | blogging

January 27, 2003

Wanna full CFMX license on the Mac?

Several folks have asked for a version of CFMX on the Mac that accepts connections from more than one computer. Well, there's nothing stopping you. Just buy a full license of CFMX for J2EE (for any platform) and, instead of installing it, use the serial number to activate your Mac version. Yep, that'll give you a full-fledged CFMX for J2EE on Mac OS X. Of course, it still won't be a supported installation and, if you even think of installing the actual version you bought - in addition to using that serial number on your Mac version - then you'll be in violation of your license agreement...
Posted by seancorfield at 10:55 PM | Comments (0) | TrackBack | cf | j2ee | osx

January 22, 2003

Accelerating J2EE with ColdFusion MX

Seybold's J2EE Promises and Customer Experiences says some very nice things about why CFMX is a great way to build J2EE applications faster and cheaper. Another nice thing it says is the part of ColdFusion's success can be attributed to its strong developer community!

Posted by seancorfield at 10:25 PM | Comments (0) | TrackBack | cf | j2ee

January 21, 2003

Another Pet Market

A lot of folks in the CF community asked if a pure CF version of Pet Market would appear so they could compare it on their terms, as a simple HTML-based application, with other implementations. You can now read all about Why We Built the ColdFusion MX HTML Pet Market Blueprint Application by Tim Buntel on the Macromedia Designer & Developer website.

Posted by seancorfield at 10:46 PM | Comments (0) | cf

CFMX, Tomcat and graphics

Some folks have reported problems with the CF_GRAPHICS_JVM_OPTIONS setting suggested for setenv.sh in the installation notes. If you copy and paste from the documentation, you'll end up with a space in the line, after rt.jar:. You need to remove this space for the options to work.

Posted by seancorfield at 04:28 PM | Comments (0) | cf

Elementary my dear Mac

Sherlock is a very cool application that Apple ships with Mac OS X. It's an integrated way to quickly browse a variety of websites, providing movie times, flight information, stock prices, dictionary lookup etc. There are also some cool add-ins for it. However, it owes a lot to the, in my opinion, superior Watson product.


I remember reading about Watson some time ago but forgot about it and never followed up. The other night, going home on BART, I got chatting to another commuter who happened to be a developer at Karelia, working on Watson. He was actually surprised I'd heard of it. When I got home, I downloaded a copy and played around. It does everything Sherlock does (except the very cool flight information channel) and much more besides. The really useful channels that Watson offers (and which Sherlock does not) include a phone directory - with reverse lookup! - and zip code lookup, integration with Amazon.com, currency exchanges, weather channel and so on. It also has a much better TV guide although the movie channel is not quite as good (the movie previews play better in Sherlock). Overall, highly recommended and well-worth $29 (or, in my case, $39 for a "household license").

Posted by seancorfield at 01:39 PM | Comments (0) | osx

January 20, 2003

Impressed

I continued to be more and more impressed with ColdFusion MX the more I use it. Over the last week, I've had two interesting problems to solve that proved to be almost trivial in CFMX. The first problem was that various business owners were writing specifications in HTML that contained lots of repetitive information that I needed in a database. The second problem was that I received a spreadsheet showing hundreds of potential configuration changes to Apache involving server-side redirects. How did CFMX help?


cfhttp lets me read HTML documents. REFindNoCase() allows me to use powerful Regular Expression pattern matching to extract information from strings. I wrote a short CFC that takes a list of HTML documents to scan and a struct containing 'static' information for the database records to be inserted from those documents. The CFC method loops over the list of documents, reading each one and repeatedly extracting data from two adjacent columns in a variety of tables which it then inserts or updates in the database. Then I wrote a simple driver CF page that calls the CFC over and over with lists of documents and metadata. I can now add arbitrary groups of documents with just a small addition to the driver page. The whole thing is less than 200 lines of code and produces a comprehensive report of successes and failures. The end result is that the business owners can change the specs whenever they want and all I have to do is hit a web page to repopulate the database!


For the spreadsheet, I manually saved it as a comma-delimited CSV. Then I wrote a few lines to slurp that into memory as an associative array (a map) followed by a few lines of code to read the Apache configuration file and cross-check each redirect against the associative array, outputting the revised configuration file when it's done. Less than 100 lines of code - and it still produces success / failure reports and timings.


The ease with which CF can read web pages and read / write files, combined with regular expression pattern matching and excellent text list processing mean that I don't have to learn Perl to do this kind of stuff - for which I'm very grateful!

Posted by seancorfield at 12:26 AM | Comments (0) | cf

January 19, 2003

Reviews & Ramblings

Another new blog, and one that I think will be interesting to watch: Fluid Code's soapbox. Right now it has a couple of book reviews and some thoughts on legacy browser support but I expect it will become a mine of information for Mac web developers over time.

Posted by seancorfield at 12:16 PM | Comments (0) | blogging

January 18, 2003

Enhancing your Mac

A neat little tweak is Application Enhancer. Once installed, you will have access to a slew of great little application tweaks. I immediately installed the Safari Enhancer which, amongst other things, makes Safari run full-screen by default rather than new windows cascading.

Posted by seancorfield at 12:22 PM | Comments (0) | osx

Baba O'Reilly!

O'Reilly's website now has a section dedicated purely to ColdFusion! There's not much there yet (mostly Dick Applebaum's series of articles on CFMX for Mac OS X) but I hope it will grow to be a valuable resource.

Posted by seancorfield at 08:59 AM | Comments (2) | cf

Flash Remoting and Security

Mesh has posted some information about Flash Remoting and the Web Services adapter. Essentially, the issue is that malicious people can invoke Web Services using your Flash Remoting gateway. You carefully put a firewall between your web servers and your CFMX app server and then discover that your internal Web Services are now accessible because strangers can ask your gateway to invoke arbitrary Web Services - including things inside your firewall. This is definitely a potential security issue but it really only becomes an issue when those "strangers" figure out the internal address of your Web Services which - for obvious reasons - you've never documented externally. So it's probably not much more than a theoretical threat.


My advice, however, is to wrap your application server in a firewall as well as your web server, and to lock down port 80 - and possibly port 443 - access from the app server to your internal network. Another option would be to disable the ColdFusion Web Services Adapter... except that Flash Remoting doesn't currently allow you to do that.

Posted by seancorfield at 12:37 AM | Comments (2) | mx

January 17, 2003

How do I keep it fresh?

A blog only works if you write something regularly. The web is full of stale content. I've seen sites where the webmaster contact email is forwarded to someone who left the company years earlier... They don't get any 'webmaster' email so they think their site is just fine(!). A few years back, when I moved to California from England, I moved my website from ocsltd.com (Object Consultancy Services Limited) to corfield.org. I took the trouble to search the web for references to my site and to track down the webmasters. Some of them were really grateful and updated their sites. Some said "thank you" but did nothing. Others were surprised their email address was still attached to an 'old' site. The web rots a little every day. We all need to spring clean. I have iCal send me an email every day at 11am to write something. I'm weeks behind - because I'm busy trying to launch a new website. But my mailbox is full of reminders and I will catch up... in due course.


One of the things I've done recently - with ColdFusion - is to write a little utility to validate URLs in our redirect system. It sends automatic email to people who created a shortcut URL that is now giving a 404 error. Spring cleaning. I've also written a little utility to read specifications (HTML documents) and extract URL and redirect information from them, upload to a database and then export to our web server. Whenever you see a URL of the form /go/keyword on Macromedia's site, it's probably been processed by a ColdFusion utility to ensure it's valid. Every day I continue to be impressed by the power and simplicity of ColdFusion...

Posted by seancorfield at 11:52 PM | Comments (0) | blogging

Yet More Mac Stuff

A colleague and fellow Mac-head, Scott, has a interesting blog. Recent stuff includes some cool Safari tips and - as always - some humor!

Posted by seancorfield at 11:41 PM | Comments (0) | osx

More Mac Stuff

I really like the default Mail app and the iCal app but I have been a little frustrated that I can't auto-generate calendar events and todo items from emails. This problem is now solved with Mail2iCal and Mail2iCalToDo. These AppleScript utilities allow you to export selected email messages as events and todo items respectively. Very convenient!

Posted by seancorfield at 11:36 PM | Comments (0) | osx

January 16, 2003

Flash for Presentations and e-Learning

A very exciting announcement today: Macromedia Acquires Presedia, Inc.. In much the same way that Macromedia Contribute enables non-technical users to author web content (in a controlled environment), so Presedia Express allows non-technical users to create presentations and other e-learning materials in familiar ways and then deliver them via Flash.

Posted by seancorfield at 02:07 PM | Comments (0) | macromedia

January 15, 2003

A Microsoft-free Laptop!

I installed the public beta of OpenOffice a few days ago making my machine a Microsoft-free zone. Sure, it's a little quirky and it's not very integrated with the O/S, but it works just fine and seems to have very good compatibility with Word, Excel and PowerPoint. Despite the caveats in the installation notes, it seemed to install just fine with the Apple public beta of X11 and the "Start OpenOffice.org" application will find and start X11 automatically.
My day-to-day software now consists of Mail, iCal, Address Book, iChat, iSync, Safari, Fire (awesome chat client for AIM, ICQ, IRC, MSN & YIM, although I prefer iChat for AIM and ChatZilla for IRC), Mozilla, OpenOffice and SQL Grinder (a excellent database tool). And, of course, Dreamweaver MX, ColdFusion MX for J2EE, JRun 4.
Posted by seancorfield at 02:00 AM | Comments (3) | TrackBack | oss | osx

January 13, 2003

Safari Updated

The current beta build is now v51. If your build is earlier (mine was v48), you'll want to go to the Safari website and download the new version. According to Dave Hyatt's blog, bug fixing is progressing pretty well so we should expect new beta builds with some regularity!

Posted by seancorfield at 10:39 PM | Comments (0) | osx

January 11, 2003

WebForums MX

I don't whether anyone else has noticed yet but the Macromedia web forums are now running on CFMX. If you haven't noticed, that's a good thing of course!

Posted by seancorfield at 05:35 PM | Comments (0) | macromedia

January 10, 2003

cfhttp & cfloop

If you have used cfhttp much, you've probably tripped over the bug that if you use it inside a loop, it's reliability degrades. I have been working on a little application that validates URLs in a database and was having problems with the reliability of the cfhttp tag.


I was stumped. Repeated calls to cfhttp gradually deteriorated into failure, with generic "Connection failure" errors. Brandon Purcell, in an off-hand moment, suggested putting the cfhttp tag call in a separate CFC and call that method from the original page with the cfloop. To my surprise, it worked! So, if you need to validate a database full of URLs, split the application up and you'll have more success.

Posted by seancorfield at 12:23 AM | Comments (0) | cf

Whither Fusebox?

Someone reminded me today that I promised to write up my experiences with converting my website from "plain" PHP to Fusebox. Yes, yes, yes. I will get to it. I'm kind of snowed right now, trying to finish the new macromedia.com (along with many other folks) so cut me some slack. I will just say that it wasn't as unpleasant as I'd initially expected... No faint praise from me!

Posted by seancorfield at 12:15 AM | Comments (0) | TrackBack | architecture | cf | php | programming

January 09, 2003

mod_rendezvous & mod_jrun

Now that Safari can use Rendezvous to auto-discover local network web servers, you might want to install Eric Seidel's mod_rendezvous on Apache. That very simple module enables Rendezvous to 'see' your Apache server.


The installer uses apxs - APache eXtenSion tool - to add the necessary directives to /etc/httpd/httpd.conf. Unfortunately, if you've already installed mod_jrun using wsconfig, then apxs seems to get a little confused and it puts the LoadModule directive in the wrong place. Here's the fix: as root, edit /etc/httpd/httpd.conf and search for rendezvous_module. You should find its LoadModule directive immediately after jrun_module's similar directive. Cut this line (dd in vi) and then search for hfs_apple_module which should be the last directive in a long block of LoadModule directives. Paste the line after the last directive in that block (p in vi

Note that if you've already tried to start PWS, it will be hung and you cannot do it from the System Preferences panel. You can start it from the command-line as root: /usr/sbin/httpd.

Posted by seancorfield at 10:54 AM | Comments (0) | osx

Surfin' Safari

Check out Dave Hyatt's great weblog about Apple's new web browser!

Posted by seancorfield at 10:38 AM | Comments (0) | osx

January 08, 2003

More Macromedia Mac OS X

A one-stop shop page for information can be found at Macromedia - Server Products for Mac Users.

Posted by seancorfield at 03:18 PM | Comments (0) | TrackBack | macromedia | osx

On Safari

Apple's new web browser is very nice although it's quite buggy. I love the look'n'feel and it's very fast. I like the minimalist mode with all the toolbars turned off. I like the integration with the Address Book (which proved how little I'd been using URLs in my contacts over the years - more on that in another blog entry!). All sounds good so far. But, like the curate's egg, it's only "good in parts".


As several people have noticed, JavaScript is poor - you can't login to HoTMaiL for example (well, you might say that's no bad thing!) - and Flash Remoting does not work (which is probably also a JavaScript issue since I believe Flash relies on the browser's JavaScript API in order to make HTTP requests). I've reported both of these through the built-in bug reporting tool (a nice touch). All the same, I'll keep using it, and l look forward to the 1.0 release!

Posted by seancorfield at 03:13 PM | Comments (0) | osx

January 07, 2003

Drool!

Back in June, I switched from Windows to Mac and got a nice shiny G4 PowerBook. At the time it was the "middle" model. Fast forward a few months and things have changed a lot. The brand new Apple - PowerBook G4 17" is an awesome machine. Aside from the stunningly obvious big screen, it has some great innovations: light sensing keyboard backlight, FireWire 800, AirPort Extreme (54Mbps!), Bluetooth... all built-in. Definitely a high "drool" factor. And a brilliant advert showcasing the new PowerBooks!

Posted by seancorfield at 11:17 PM | Comments (0) | osx

CFMX for J2EE on Mac OS X

I downloaded the Mac edition and discovered it is a .jar file. I was hoping it might be. The installation offers you a .ear file deployment or a .war file deployment - I chose WAR file and was rewarded with cfusion.war and rds.war. Out of curiosity, I went to my Tomcat installation and created a new cfmac directory under /home/tomcat/webapps. Then I unpacked the cfusion.war file (jar xvf ~/CFMXJ2ee/cfusion.war) and restarted Tomcat. http://localhost:8080/cfmac/CFIDE/administrator brought up the ColdFusion MX Administrator.

Of course, Tomcat doesn't give you all the features of JRun, but it's interesting to see it running on top of Tomcat, alongside my installation of BlueDragon!


1.8.2003 - Guess I should RTFM since that provides full instructions for installation on Tomcat!
Posted by seancorfield at 11:05 PM | Comments (0) | TrackBack | cf | j2ee | macromedia | osx

More Mac OS X Goodness

Christian Cantrell has plenty to say about this in his article, Macromedia - Designer & Developer : Logged In: Macromedia Expands JRun and ColdFusion MX for J2EE to the Macintosh OS X Platform.

Posted by seancorfield at 07:00 PM | Comments (0) | TrackBack | cf | j2ee | macromedia | osx

JRun & CFMX for OS X

It's sort of 'old' news, even though the announcement has not been made officially. Macworld has this snippet from the Expo - ColdFusion gets X support. The downloads are accessible on macromedia.com: JRun 4 Developer Version, ColdFusion MX for J2EE (JRun Mac OS X Developer Edition). JRun for Mac OS X can also be purchased in the Online Store. No doubt there will be a lot more information published about this later today.
Posted by seancorfield at 10:17 AM | Comments (0) | TrackBack | cf | j2ee | macromedia | osx

January 06, 2003

cflock (again)

It's been a while since I posted about good practice locking but an issue keeps coming up which needs to be written down: I see a lot of code like this:


<cfif not isDefined("application.somevar")>
<cflock type="exclusive" ...>
<cfset application.somevar = somevalue>
</cflock>
</cfif>

This isn't safe! Consider what happens if two requests hit this at the same time - they can both find application.somevar is not defined and then they'll both initialize it. The cflock only ensures that the updates will be done one at a time. In order to be safe, the entire condition needs to be locked to ensure only one request will actually initialize things:


<cflock type="exclusive" ...>
<cfif not isDefined("application.somevar")>
<cfset application.somevar = somevalue>
</cfif>
</cflock>

Now the cflock ensures the variable will really only be initialized once.




1.8.2003 - Thanx to Marcello Frutig for spotting an error in my original post (a missing not) and also for a performance tweak: as written, the code above will effectively single-thread every request which is potentially a big deal. Since we're only trying to avoid race conditions, Marcello suggested the following idiom which is much better:


<cfif not isDefined("application.somevar")>
<cflock type="exclusive" ...>
<cfif not isDefined("application.somevar")>
<cfset application.somevar = somevalue>
</cfif>
</cflock>
</cfif>

This ensures that no requests will single thread once the application has been fully initialized but still avoids race conditions during initialization. Neat! Thanx Marcello!

Posted by seancorfield at 11:07 PM | Comments (2) | cf

MacWorld

I wish I could be at MacWorld... Macromedia has a large booth there this year but I haven't heard many details about our presence, other than it's bigger than usual. As always, it'll be interesting to hear what companies are announcing this year - there seems to be some real gems every year. I heard that one company is offering an interesting prize in their competition: an H2 (Hummer). Just the thing for driving around town!


But I can't spare the time... My team's project is at a very exciting stage now as we iron out the final kinks in the system and do performance tuning and load testing. I'll be publishing more 'tidbits' here in due course and preparing articles for the Macromedia Designer & Developer Center.

Posted by seancorfield at 10:53 PM | Comments (0) | osx

A New Macromedia Blog

The recently appointed Server Community Manager has just launched his web log - Christian Cantrell's Perspective - and it's all written in ColdFusion MX! This should be a blog worth reading regularly.

Posted by seancorfield at 10:22 PM | Comments (0) | blogging

January 02, 2003

CFMX for J2EE: Shared Document Root

Previously, I talked about how to set up multiple CFMX for J2EE instances on your J2EE server and noted that each instance had it's own document root. Now I'm going to tell you how to have these instances share a common document root - so you only have to have one copy of your CF source files. Unfortunately, it's not entirely straightforward and I'm much beholden to Brandon Purcell for his help in ironing out the specifics of how to do this with JRun.
First of all, you can't simply have the entire document root shared. CFMX has a WEB-INF directory which contains server instance specific data and therefore that cannot be shared. This means you have to be a little creative!
Second, some CFMX code expects the WEB-INF directory to be underneath the document root. Fortunately, this 'fixed' section can shared.
Once again, we have to edit XML files to make all this happen. For each server instance, edit the jrun-web.xml file in {jrun.home}/servers/<instance>/cfusion/WEB-INF/ (assuming your context root is /cfusion). The end of the file looks like this - remove the section in red (if present) and add the section in blue:
  <virtual-mapping>
    <resource-path>/</resource-path>
    <system-path/>
  </virtual-mapping>
  <context-root>/cfusion</context-root>
  <compile>false</compile>
  <reload>false</reload>
  <uri-character-encoding>UTF-8</uri-character-encoding>
  <virtual-mapping>
    <resource-path>/*</resource-path>
    <system-path>{cfmx}/wwwroot</system-path>
  </virtual-mapping>
  <virtual-mapping>
    <resource-path>/WEB-INF/*</resource-path>
    <system-path>{jrun.home}/servers/<instance>/cfusion/WEB-INF</system-path>
  </virtual-mapping>
</jrun-web-app>
{cfmx} should be replaced by the common document root you've chosen for CFMX, {jrun.home} should be replaced by the JRun install directory and <instance> should be replaced by the name of the server instance whose XML file you are editing.
If the section in black isn't present, you can add it although it represents the defaults.
This removes the default document root mapping (in red) and adds two new mappings (in blue):
  • a document root mapping to the shared document root
  • a WEB-INF mapping to ensure each server instance can find its own private library files
I typically add a third mapping (of /CFIDE/*) to the instance's CFIDE directory - to save having to copy the CF Administrator code from the CFMX for J2EE install out to the common document root. It's up to you - I find it convenient because of the automated builds I do on my systems.
If you put your own libraries in the shared document root's WEB-INF area, under classes or lib, then you need to add those directories to the java.class.path in jvm.config.
Finally, you need to copy the WEB-INF/cfusion/lib/jrun.properties file out of one of the server instances to the corresponding location under the shared document root. This is the piece that has to reside under the actual document root rather than the installed WEB-INF.
Posted by seancorfield at 11:05 PM | Comments (0) | TrackBack | cf | j2ee

January 01, 2003

JRun Clustering & Session Replication - How does it do that?

Both clustering and replication work over the network and do a lot of things automatically for you. If you have two physical servers on the same network subnet and create clusters on both of them using the same cluster name, then the clusters will automagically find each other when you start them up. That means the server instances on each of those physical servers needs to be unique across both servers - server instance names must be unique within a cluster and a cluster can span physical servers. Similarly, session replication can be set up to have an application on one server instance buddy up with a set of other server instances running that application, anywhere else in the extended cluster. Once the server instances are up and running, buddies will automagically find each other.


Let's look at a slightly more complex setup and see what this allows us to do. Consider the following server setup:


  • Server 1, instances cfmx11, cfmx12, cluster cfmxprod

  • Server 2, instances cfmx21, cfmx22, cluster cfmxprod

  • Server 3, instances cfmx31, cfmx32, cluster cfmxprod

Three physical servers, each with two instances of CFMX, using the same cluster name on all three servers. If you connect your web server to this cluster, wsconfig will set things up so your web server will 'boot' off one of the instances but will then treat all six instances as 'proxy servers' (in the jrunserver.store file). Any request (to a /cfusion context root if you followed some of my naming conventions) will be routed to one of the six instances (and that session will then stay on that server).


If you take down one of your servers, any active sessions will be lost unless you've set up session replication. So let's assume we've set up session replication as follows:


  • cfmx11 buddies with cfmx21 and cfmx31

  • cfmx12 buddies with cfmx22 and cfmx32

  • cfmx21 buddies with cfmx11 and cfmx31

  • cfmx22 buddies with cfmx12 and cfmx32

  • cfmx31 buddies with cfmx11 and cfmx21

  • cfmx32 buddies with cfmx12 and cfmx22

With this setup, each server instance has buddies on other physical servers. That means that if we take down one physical server, all active sessions on that server will migrate to their buddies. Let's reboot Server 1. Active sessions on cfmx11 will migrate to either cfmx21 or cfmx31 and active sessions on cfmx12 will migrate to either cfmx22 or cfmx32. No downtime for your users!


So, how does it do that? It uses JINI. JINI let's each server broadcast its services so that other servers (on the same subnet) can automatically discover them. JRun's clustering mechanism uses JINI to discover other servers on the same subnet that host clusters with the same name - and merges them all into one big cluster. Similarly, replication uses JINI to discover on which servers the named buddies exist so that session data can be shared over the network. This is a good example of how powerful JINI can be - you don't need to configure other hostnames or IP addresses into your system: JRun just takes care of it for you. But you do need to be slightly careful - JRun searches the subnet for matching cluster names so if you have a cluster called cfmx on your machine and your colleague also has a cluster called cfmx on his machine, you could suddenly find both machines sharing the load! Choosing your cluster name is therefore quite important!

Posted by seancorfield at 08:17 PM | Comments (0) | cf

CFMX for J2EE: Session Replication with JRun

If you've created your cluster (see below), you may decide to make your system more robust by enabling session replication. There are some important caveats however:
  • You cannot enable session replication if you store any CFC instances in session scope. CFC instances do not serialize / deserialize fully (because they are full-blown Java objects and session replication is not designed to replicate complex Java objects, only simple data types).
  • Session replication works over the network and, for CFMX, cannot use the file-system persistence feature mechanism in JRun.
Having decided to enable session replication, here's how you go about it in JRun. This assumes you have already created a cluster according to my earlier blog entry with server instances called cfmx1, cfmx2 etc. As before, load the JMC in your browser and do the following:
  • On the Home page, in the main frame under Application Servers, click cfmx1 to see the J2EE Components on that server.
  • Under Web Applications (main frame), click CFMX Application to see the overview of that application.
  • Check Enable Session Replication (this auto-enables File-based Session Persistence which we will disable manually later).
  • For New Replication Buddy, enter cfmx2 and click Add
  • cfmx2 should now be displayed in the Session Replication Buddy List
  • Click Apply
  • Go back to the Home page - click the Home link in the top left corner.
  • In the main frame under Application Servers, click cfmx2 this time to see the J2EE Components on that server.
  • Under Web Applications (main frame), click CFMX Application to see the overview of that application.
  • Check Enable Session Replication (again, this auto-enables File-based Session Persistence which we will later disable).
  • For New Replication Buddy, enter cfmx1 this time and click Add
  • cfmx1 should now be displayed in the Session Replication Buddy List
  • Click Apply

Now you need to disable File-based Session Persistence because it conflicts with the CFMX custom class loader. You can't do this inside the JMC so you have to edit the jrun-web.xml file for each server instance using your favorite text editor:

  • {jrun.home}/servers/cfmx1/cfusion/WEB-INF/jrun-web.xml
  • {jrun.home}/servers/cfmx2/cfusion/WEB-INF/jrun-web.xml
The session config section needs to looks like this:
    <session-config>
       <persistence-config>
          <active>false</active>
       </persistence-config>
       ...
By default, the <active> flag is true, it should be changed to false as shown above.
Now restart your server instances and your session data will magically be replicated between server instances!
Posted by seancorfield at 07:50 PM | Comments (0) | TrackBack | cf | j2ee

CFMX for J2EE: Creating a JRun cluster

In order to cluster CFMX instances, you need to have multiple server instances, each containing a CFMX installation. For example, I create server instances called cfmx1, cfmx2 etc and then a common context root of cfusion under each of these. Then I create a cluster in JRun and add in the server instances. Note that JRun clusters contain server instances - a server instance can contain several different applications, each with their own context root. A request to the cluster for a particular context root will be served by any one of the server instances that have that context root. More on this later.
For JRun, open the JMC (JRun Management Console) in a browser and do the following:
  • Click Create New Server (top nav, main frame) to get the add server pop-up
  • Enter cfmx1 as the JRun Server Name
  • Click Create Server
  • On the next page, you can change the port number if you wish to use your own scheme rather than whatever JRun allocates for you - I use 8300, 8400 etc for the Web Server Port Number and 51030, 51040 etc for the Web Connector Proxy Port Number - then click Update Port Numbers
  • Click Finish and the pop-up will be dismissed
  • Click Refresh Now if necessary on the main panel to show the updated port numbers on server cfmx1
  • Click Create New Server again and repeat the process for server name cfmx2 (and change the port numbers if desired)
  • Click Refresh Now if necessary on the main panel to show the updated port numbers on server cfmx2
  • Click Create New Cluster (top nav, main frame) to get the add cluster pop-up
  • Enter cfmxXXX as the Cluster Name where XXX identifies the system, e.g., cfmxdev.
  • Click Next
  • Select both cfmx1 and cfmx2 from the list and click Next
  • It should confirm the servers were successfully added - click Done
Now you can start both CFMX server instances and then run wsconfig to configure your web server connector to talk to the cluster you just created.
Posted by seancorfield at 07:34 PM | Comments (0) | TrackBack | cf | j2ee

CFMX for J2EE: Manual Installation

When you download your copy of CFMX for J2EE, you have a couple of options for installation. My preference is to have the installer produce the EAR file cfusion.ear and then do a manual installation of this. The installer asks for your CF Admin password and the context root - if you do a manual installation, the context root you entered in the installer is irrelevant because you can control the context root later. Once you have cfusion.ear, unpack it manually:
jar xvf cfusion.ear
This creates cfusion.war, rds.war and a META-INF directory.
Now go to your J2EE server instance where you want to run CFMX. Create a directory, named for the actual context root you want, e.g., cfmx. Go into that directory and unpack the WAR file from above (jar xvf /path/to/cfusion.war). If you want to enable RDS to this server, you need to create a CFIDE context root directory (alongside the directory you just created above) and unpack the small RDS WAR file there (jar xvf /path/to/rds.war). Start your server instance and then, in your browser, open http://<server>:<port>/<contextroot>/CFIDE/administrator/index.cfm. Go through the first time dialog and you're done!
I've been installing servers this way on JRun (and other J2EE servers) and, whilst it may seem like extra work, it's actually more flexible - you don't need to re-run the entire installer every time, just create a directory and unpack the WAR file. Depending on the functionality of your J2EE server, you may now create a cluster of these instances - I'll show how to do that in another post shortly. Note that each context root has its own ColdFusion document root - the directory you created under your server instance. In another post, soon, I will show how to have server instances share a common document root.
Posted by seancorfield at 07:02 PM | Comments (1) | TrackBack | cf | j2ee