Why Can't I Run More Than One Server Instance at the Same Time?

Many developers, myself included, like to set-up their local development environment to run ColdFusion on top of a local J2EE Application Server. There are a lot of reasons to do this: you can run multiple instances (and play with J2EE settings per instance), run different versions of CF side by side, and deploy other J2EE apps (like LCDS or BlazeDS) to name a few.

I was recently setting-up a new development machine in this manner: installing databases, IDEs, application servers, etc. After running through the whole set-up, which is something I can do in my sleep having done it so many times over the years, I was surprised to find that this time, for some reason I couldn't start any instances on the machine. Slight correction - whenever an instance was already running I couldn't start any other instances... that's important to note. This was a first for me.

Whenever this happens you should immediately suspect your jvm.config file, as it's shared by all your instances when they start. If something in that file locks a resource (usually a port) then the other instances won't be able to start. You should also, if you aren't already doing so, immediately try starting your instances from a console window so that you can see what's going on when the instance tries to start. The culprit, as it turns out, is the ColdFusion 8 debugger.

In order to use the interactive/step debugger that ships with CF 8, you need to set up and use the Eclipse/CFEclipse debugging environment, but not before first configuring your server for debugging. The instructions are in the CF Documentation - online at http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=usingdebugger_4.html. If you read the instructions in the documentation you'll note that in a J2EE (multi-server) environment, in addition to enabling/configuring debugging in the CF Administrator, you also need to add a few extra arguments to your jvm.config file. The arguments look like: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address= - where matches the port number in the CF Admin debugger page. The default port is 5005. Not so coincidentally, the errors I was seeing in the console window were all alluding to the fact that port 5005 is already in use.

So, if you want to use the interactive debugger in a multi-server environment, be sure to have each J2EE server instance start-up using a different config file (use a "-config" flag at the command line or in the service definition) and in each config file specify a unique debugger port: making sure, of course, that each instance running ColdFusion also specifies the same unique port in it's CF Admin debugger page. On Windows you can see what ports are currently in use by opening a command prompt and typing: netstat -an |find /i "listening". If you have instances not running CF, they can all start with the same jvm config file... provided that it doesn't contain the parameters for CF debugging. I haven't tested this, because my other instances didn't need debugging, but I hazard to guess you can use pretty much any port not already in use as a debugger port. The documentation doesn't mention any of this... at least not anywhere that I could find.

I was really surprised that nobody has blogged about this issue, but I searched a bit and didn't see anything. I keep getting the odd feeling that there must be something I'm missing... but until I find it, I'm going to call this one a bug (in the documentation, at least). Hopefully, this entry helps someone out there who's banging their head against the wall...

Comments
You are correct Simon,

you can have multiple instances running each one pointing to a difference port number and be able to debug each one of them. What I usually do after creating a new instance is to unregister the instance and re-create it (like explained here http://mkruger.cfwebtools.com/index.cfm/2006/4/17/... ) .
# Posted By João Fernandes | 7/4/08 8:38 AM
Simon, good of you to blog it. As for it not having been mentioned before, well, I'll note that I've mentioned it in the talks and articles (and book chapters) I've done on using the CF8 debugger.

This is one of those situations where I made the mistake of assuming that that was enough to share what I'd observed. :-) There are all kinds of things like that where I've shared tips but haven't blogged it all.

Anyway, as for pointing out this challenge with the multiserver deployment and the debugger, some of the resources do come up in a search (pdfs for talks) while some do not (the PDF of the CFWACK book chapter, which I point to at http://carehart.org/blog/client/index.cfm/2008/2/1...). Some aren't even online (my FAQU article where I mention this).

Anyway, good to see it shared as a blog entry. Thanks.

As for regarding it as a bug in the docs, did you add a comment in the livedocs? That will help many.
# Posted By Charlie Arehart | 7/7/08 1:18 AM
This site is hosted by HostMySite and runs off of BlogCFC - thanks, Ray.