Archive for October, 2008

29
Oct

October CINNUG – Silverlight 2

Really informative and engaging CINNUG last night as Matt Casto demo-ed much of his work in Silverlight 2. Of course, with Mike out of town there had to be technical difficulties. We couldn’t get the projector working with Matt’s laptop. With a bit of finageling Tim Apke got Matt setup on his Mac.

A boatload of people attended including Rich Rayburn, Parag, Phil Japikse, Matt Brewer, Joe Wirtley, Nino Benevenuti, Peggy, Maggie Longshore, and Leon Gersing to name a few.

Ryan Cromwell from SDS kicked off the evening once we figured it might take a while to get Matt up and running. Ryan did a quick presentation on the visitor pattern.

Ryan Cromwell - Visitor Pattern

Ryan Cromwell - Visitor Pattern

The bottom line: Don’t muddy entities classes with unrelated logic, get away from single responsibility.

Matt Casto - Silverlight 2

Matt Casto - Silverlight 2

Most of Matt’s presentation was a demo of Silverlight 2, so there isn’t a whole lot to report on. Much of the night we spent modifying XAML and seeing what happens. Yet there were a few nuggets of valuable information.

Silverlight is the Microsoft browser plugin usually likened to Flash. From a developer perspective, the difference is that Silverlight is based on XAML, a declaritive language, to define UI, where Flash uses other descriptors. Silverlight supports vector graphics to ensure a detailed rendering at any resolution.

The XAML standard supports full 3D. Someone commented that perhaps you could load 3D renderings into XAML designer. A team somewhere is developing a Quake port to Silverlight.

WPF, the superset of Silverlight maybe, has a number of new user controls – announced at PDC – that make developing user interfaces in Silverlight a much less tedious process. When you write your own controls in Silverlight you wind up writing the same code over and over. The addition of Visual State Manager allows a developer to define styles that can then be applied to states. This paradigm reduces the amount of customization necessary for each individual control in the UI. Check out codeplex for details.

Expression Blend is the designer oriented tool for WPF and it contains a storyborad editor.

Parag using Expression Blend

Parag using Expression Blend

Other controls include the treeview, doc manager, view panel, auto complete, and others. Again, the code is available on codeplex.

Is Silverlight ready for the enterprise? What’s the standard technology answer? “It depends.” Some enterprises do WPF work now, so the integration of Silverlight may not be a big issue. A problem with Silverlight is that all the stuff resides in the .xap file, so a change requires a full download to the client. There are ways to split this up, but the problem is not solved yet. Also, printing doesn’t work consistently, or even well, across browsers. A kludgey work-around includes implementing a managed bridge to Javascript where you layout  elements in a div in the page the way you would want it printed out. Crappy, but it’s the best solution at the moment.

Can grids compare to the .NET grids? It depends. Silverlight runs in a mini-framework pared down. You don’t get all the functionality of .NET. Yet, it’s a 4.3MB download, so a tiny footprint.

Microsoft is partnering with Novell to develop Moonlight, a Silverlight for Mono implementation that targets non-Microsoft platforms.

The bottom line? Most IT shops don’t blink at Flash as a requirement, so Silverlight may be a targetable platform.

- Andy

29
Oct

October CinArc – Who’s Responsible for Code Quality

There’s something to be said for smaller groups. Around 10 of us had some great discussion about developing efficient processes to move builds from dev to test to prod and about an architect’s responsibility for code quality. Leon Gersing, Mike Levy, Mike Wood, Maggie Longshore, Nino Benvenuti, and some others talked around the table, fishbowl style, at Max Training in Mason.

A quick note about future meetings. The new date will be the 3rd Thursday of each month as Max is consolidating user groups to Thursday evenings. So check the dates of your favorite group. Chances are the date has changed. CINNUG, by far the largest group to meet at Max, is the only exception as it will keep the 4th Tuesday of the month schedule.

I gotta get some exciting announcements out of the way. The 10/28 CINNUG will feature ineta speaker, Matt Casto, talking about controls in Silverlight 2.0 (yeah, I’m publishing on 10/29 – it was a great presentation, though). The 11/25 CINNUG will be the culmination of the membership drive and you’ll want to be there to hook some awesome swag. We’re giving away an xbox 360, a 1-year subscription to Safari Books online, and 1 MSDN premium subscription valued at $10,000 that includes VSTS. You have to be present to win. You get one entry in the give aways for each meeting you attend and for each new friend that comes with you. So you still have Oct CINNUG, Nov CinArc, and Nov CINNUG to earn entries. Bring some people with you.

November 17th will feature a CINNUG special meeting (and, yes, it counts towards entries in the giveaway) where Microsoft’s Mark Mydland will present on VSTS Tester edition. Mark manages the development and QA teams responsible for Visual Studio Team System for Software Testers, and he’ll take us on a deep dive of what to expect in future releases. 6PM at Max Training.

Other odds-n-ends include the next MSDN event on 11/5 that will cover SQL Server 2008. PCD keynotes will stream live this year. Expect announcements and unveiling of Microsoft’s implementations of cloud computing, Oslo, and distributed computing.

Back to CinArc. Our first topic was the process for moving builds from dev to test to prod efficiently. The notes are in raw form below for those who are interested in following along. I’m way behind on posting, and I didn’t have a lot of time to make it all nice and pretty. You can thank Matt Brewer for a great job on the notes.

Creating/Designing Dev-Test-Prod Environments – Handling the differences (Mike Wood)

Topic Synopsis:

  • How do you architect a solution to ease the transition of code artifacts between dev-test-prod environments?
  • How do you handle the differences between these environments?

I’m already late on getting this out, so here’s a raw dump of the notes.

Creating/Designing Dev-Test-Prod Environments – Handling the differences

Topic Synopsis:

  • How do you architect a solution to ease the transition of code artifacts between dev-test-prod environments?
  • How do you handle the differences between these environments?

Discussion:

  • Are Web Apps the answer? Helped to take five deployment steps down to one
  • How to handle Test and Prod when dealing with outsourced/offshored development shops? Hard to prevent code churn.
  • Is there an inherent policy problem?
  • Try to get as close to a “click-to-deploy” as possible via automation
  • Change management Red Tape – grows over time
    • Find an external partner to help define the process – Helps keep politics to a minimum.
  • There is a perception that Change Management process provides throttling which in turn produces quality. “It takes time to do things right”
  • Communication is key
    • Project Management -> Change Management
    • Processes need to align
  • Projects need to bake in time
  • If following an Agile approach –
    • Start to invite the operations folks to stand up when sprint is 75% complete.
    • This gives them time to start on your infrastructure needs
  • Know how to correctly test before moving environments
  • The solutions architect must act as a “Broker” in the process

Key Conclusions:

· Baking in project time to do the change management function

· Communication with operations

· Involving the right people in the project at the right time

o E.g. Inviting Ops to daily scrums at a certain time in the sprint

Moderators Note: This topic obviously went off course from Mike’s original intent. We talked more about the process of change management slowing down time to market than how to architect system to move across environments easily.

Architects Managing Code Quality

Topic Synopsis:

  • Is Quality a last priority?
  • Where does Quality fit in the software development lifecycle?
  • Quality as defined by Leon: Reducing Cyclomatic Complexity, Following good OO principles (SOLID)
    • It is not just following coding standards

Discussion:

  • Code Reviews with everyone involved
    • Maintain a wiki of the reviews
    • Frequency: once a week starting out, taper off over time to specified intervals – be consistent
  • How do you fight the “If it runs, it’s good enough” mentality?
  • Code review need to be done on everything – including patches
  • There needs to be leads (architects) that are constantly training/retraining devs on the process
  • Book from Parasoft CEO (link needed)
  • Creating a culture of shared responsibility for quality
    • Lean Manufacturing – “Pulling the Rope”
  • Having the proper tooling for a team code review is very important
    • Helps streamline the process
  • Explicitly ranking quality
    • Where does quality fall in the Time – Features – Cost triangle?

Key Conclusions:

· Quality is fostered through a process of code reviews with architects at the lead

· Everyone on the team must be involved review the code

· Collective ownership of code helps to drive quality

Mike had a number of great reads to give away including

The Enterprise and Scrum

I. M. Wright’s Hard Code (Best Practices)

- Andy

16
Oct

Bangalore Traffic

I came across this email from a friend, Brian Smith, that he wrote to me a few years back. If you’ve been to Bangalore then this will ring hilariously true. If not, it’s a real description of what you can expect on the streets. I’ve lived it. I thought I’d share it with you.

- Andy

DRIVING IN INDIA

It has been an experience driving in Bangalore, as well as between Hyderabad and Kakinada (a 10.5 hour road trip). At times it has been hilariously funny; at times it has been pretty intense; there were a couple of times that I was actually scared for my life. But what a riot it is to drive in India.

Because of the trip that I have taken to Kakinada, I have discovered that there are two different styles of driving: Urban driving and rural driving.

URBAN DRIVING

The best way that I can describe how the traffic flows in Bangalore is like an active river with boulders in the flow. The water of the stream is constantly shifting this way and that, rolling around the boulders without giving them much notice, carrying along with it all types of leaves and twigs and bubbles.

Yes, I know there are lines painted on the road. I don’t know why the government spends money painting those lines; they don’t mean anything. The river just flows…

Except instead of hearing the gentle gurgle of the water, you are hearing the constant chatter of horns. All kinds of horns. Small horns on mopeds all the way up to the large (and very intimidating) air horns on the large trucks. It is amazing how much can be said with the delicate toot on the horn, or a long, constant blast of the horn. The horn is used to communicate many things, such as:

“Hey buddy, I’m right off your back bumper so don’t slam on your brakes.”
“Hey buddy, you are veering close to my car. Try veering the other way.”
“Hey buddy, the light is about to turn green. Get ready.”
“Hey buddy, we’re all stopped in traffic. Isn’t it a lovely day?”
“Hey buddy, I’m coming around the corner so if you’re in the street you better get out of the way.”
“Hey buddy, I would like to take that space in front of you, please.”
“Hey buddy, it’s OK for you to take that space in front of me. Have a good day.”
“Hey buddy, I’m going to pass you because you are slow and I am zippy fast.”
“Hey buddy, I see that you are passing me. Have a nice day.”
“Hey buddy, that maneuver you just pulled was stupid. You should have looked in your mirrors.”

Oh yeah, mirrors. Mirrors are sooo over-used in America. You see, you just have to flow with the river. If you want to pass the person in front of you, just start veering to the right and give him a courteous toot to let him know. If there is a person on your other side who does not approve, he will let you know. If you want to turn onto a new road that is very busy, you don’t need to look and merge – you just turn; the river will flow around you. You don’t need to look where everyone is; you just need to listen to the sound of the horn. These ears of ours hear very well in three dimensions. I suppose instead of vision tests, they get hearing tests over here (that was a joke).

It is not unusual for the side mirrors to be removed (either with tools or the blunt force of another object hitting it). A large number of vehicles have some type of visible damage from minor accidents. For that matter, most traffic equipment (signs, gates, curbs, poles, trees lining the streets, etc.) shows evidence of being abused by the passing stream of traffic. I was surprised to learn that the concept of car insurance does exist in India, and the rates are actually quite cheap. The downside is, of course, that it is difficult to get a
payout from your insurance company, so it is not even worth the time to pursue claims for small repairs.

Regardless of the size or condition of the road, it is shared by all. Any time between 6:00 am and 12:00 am, there will always be traffic, and achieving speeds higher than 60 kph is difficult and short-lived. Every road will at all times simultaneously have the following travelers: Pedestrians, dogs, goats, cows, bicycles, bicycle
rickshaws, bicycle carts, auto rickshaws, mopeds, motorcycles, cargo rickshaws, all types of cars and small vans, carts pulled by oxen, farm tractors pulling a load, lorries (a cargo truck smaller than a US semi truck), construction vehicles, and large buses.

It is not unusual for a driver to suddenly make a decision to turn across multiple lanes of traffic. It is not unusual for brake lights to not be functioning correctly. It is unusual for a driver to use a blinker to indicate a turn or lane change ahead of time. A driver must stay constantly alert for how the river is flowing and plan
accordingly ahead of time. Somehow, even with all of this variety and chaos, only a few people (and maybe a couple of animals) are killed a day.

It is amazing to see what can be transported on a head or bicycle or motorcycle. Bunches of bananas, mounds of mangos, round bags of rice, piles of pans, loads of laundry baskets… Truly, it is an amazing
feat in some cases to strap on the cargo and travel all the way to the destination without losing the load, crushing the driver, or breaking the vehicle. In fact, it is rather common to see a standard motorcycle
carrying mom, dad, and two small children. It is common to see an auto rickshaw carrying four passengers. Truly, truly amazing.

Most busy intersections have traffic signals. Most travelers obey the traffic signals most of the time. If the intersection is regulated by a traffic officer, the travelers obey his commands for fear of having to “negotiate” the price of an infraction.There are certain busy intersections that don’t have traffic signals,
but should. In those cases, you’ve just got to push into the cars in front of you or you’ll never get across the street. Don’t worry that the cars in front of you are traveling perpendicular to the direction that you are going, and they are pushing into you to get across the street in their direction; with a little chatter via the horn, everything will be just fine.

Almost all vehicles are driven by men, but every once in a while you see a woman driving a more feminine-looking motorcycle or scooter. If a woman is a passenger on a motorcycle, most of the time she will sit
side saddle, but sometimes she will be sitting normal; it depends on the type of clothes she is wearing, since most women wear the equivalent of a dress.

RURAL DRIVING

There are large roads that are the equivalent of a nice four-lane divided highway in the US with a posted speed limit of up to 80 kph. The traffic thins out a bit out in the country, yielding the tempting
possibility of actually using 5th gear. There is no concept of getting a speeding ticket, so if the driver if bold enough they may have the ability to reach upwards of 120 kph.

Unfortunately, as stated previously, the road is shared equally by all. Even if you get a nice stretch of open road where you can kick it up above 100, you never know when there will be a farm tractor or a herd of buffalo just around the next corner. This forces a natural speed limit on the driver that is often less than the posted speed limit, and this tension between high-speed and low-speed travelers is very abusive to the horn, the high-beams, the brakes, and the nerves.

It seems that many drivers can’t seem to fathom why the government built two roads that exactly parallel each other. I mean, two entire lanes going in a single direction?! What a waste of good pavement. So it is very common for cars to actually turn the “divided highway” into “two parallel roads” by driving in the wrong direction for the lane.

The phenomenon of completely ignoring painted lines is apparently relegated only to the city of Bangalore; drivers outside of Bangalore did maintain better lane discipline, but are still much more loose about passing on the other side of the street than us tight Americans.

Hitch-hikers are very common. There are many men who need to travel (mostly for work) but cannot afford a vehicle or a bus ride. The lorries seem friendly enough to pick up these people, and it is common to see upwards of six people riding on top of the load of a truck (20 feet up, open air, no seat belt).

Paved roads are in good condition most of the time. If a road is not paved, however, you must travel very slowly. The roads of a village are usually not paved. Nearly all city roads are paved. With the notable exception of how travelers actually use them, the roads themselves are equivalent to the highway system (not the Interstate system) in America.

Conclusion: It is best to say your prayers and be right with God before leaving for your destination.

A motorcycle with a fairly light load

A motorcycle with a fairly light load

Waiting at the "bus stop". Notice the guy on the left going the wrong way

Waiting at the bus stop - Notice the guy on the left going the wrong way

An excellent example of an auto rickshaw - these two-cycle engines belch smoky exhaust

An excellent example of an auto rickshaw - these two-cycle engines belch smoky exhaust

An excellent example of a bicycle rickshaw - they were all in this same condition

An excellent example of a bicycle rickshaw - they were all in this same condition

A woman sitting side-saddle

A woman sitting side-saddle

A typical view of the street showing a variety of vehicles. Notice the guy on the left going the wrong way

A typical view of the street showing a variety of vehicles. Notice the guy on the left going the wrong way

Riding on a lorry - 5 passengers hoping there isn't a bump in the road

Riding on a lorry - 5 passengers hoping there isn

Bunches of bananas on a bicycle

Bunches of bananas on a bicycle

An ox-drawn carriage

An ox-drawn carriage

Riding on a lorry - 7 passengers hoping no one bumps from behind. There were probably an additional four or five passengers in the cab

Riding on a lorry - 7 passengers hoping no one bumps from behind. There were probably an additional four or five passengers in the cab

15
Oct

UC Dept Of IT And A Pretty Amazing Story

For the last 8 years a consensus has begun forming around IT Education. Where CS focuses on theory and mathematics and IS on the big picture, IT Education sits somewhere between the two at an implementation level of integration, security, and management. UC’s IT department has a long history of influence in shaping what an IT focused education should require. To that end, the international ACM SIGITE conference (Association for Computing Machinery Special Interest Group IT Education) will be hosted by UC’s IT program and held at the Millenium Hotel in downtown Cincinnati this Thursday, October 16th through Saturday, October 18th.

I bring this to your attention because if you’ve followed my work, you know how much respect I have for both UC’s IT program, hosted in the College of Applied Science (CAS), and their students. Each year I’m amazed at the quality of the senior design projects and the collaboration between faculty, staff, and the community to make a real difference with the projects they choose. The outcome of senior design and the quality of student is no coincidence. The program design as well as its alignment with the real world set the graduating seniors up for great opportunities and well-paying, interesting jobs at graduation.

Browse through the conference link above and take a look at what our education community is doing to create a strong technology foundation in the research-development-application triangle. For UC to host this international conference is a great honor, and I have no doubt that other university programs will walk away with a high level of respect for what UC has compiled. Out of the ACM SIGITE Accrediting Board for Engineering and Technology, the UC IT program is one of the first 10 programs in the nation to receive accreditation.

Great job! Kudos to department head, Hazem Said, for putting together a great team!

- Andy

14
Oct

October ArcReady – Architecting Modern Distributed Apps

Brian Prince, the regional MS enterprise architect evangelist, presented October’s ArcReady event at the Mason Microsoft offices. Brian noted that the PDC keynotes will stream live this year, so pay attention and listen in for all the big MS announcements. The Q2 ArcReady event on December 2nd will focus on some of the soft skills of architecting your career. It’s a FREE event, and you can register here.

This month’s meeting focused on architecting distributed applications. Surprisingly, a lot of references to Salesforce.com, a platform I’m fairly intimately familiar with at LUCRUM. We use SFDC and have been able to do some pretty amazing things with it in very short amounts of time.

Trends in distributed app architecture certainly include SOA and the promise of reuse to drive IT agility. The goal with SOA being the ability to respond in, say, less than 9 months to the business users’ requests. SaaS, another delivery model and the Salesforce way, brings scalablity to single instance/multi tenancy to services delivery. And you get to offload the infrastructure to someone who cares. Web 2.0 is the framework that exposes and builds into applications collaboration and the network affect. As an aside here, if you ever get the, ehem, priveledge of working with any Blackbaud products, they would be the opposite of Web 2.0. Rich Internet Apps is another trend harnessing the UI power of Javascript and interesting design to create compelling user interfaces. And finally, cloud computing brings the utility model to computing with services such as Amazon’s S3 where you can spin up Linux servers as the need arises.

Options available to architects need to balance the tension between control and economy of scale where combinations include

  1. On premesis hosted in your own data center
  2. Hosted solutions running your own code on someone else’s infrastructure
  3. Running your own bits on the cloud
  4. Purchasing or leasing a vendor supplied app in the SaaS model

Build vs. Buy becomes your next choice as you need to balance strategic value against control based on each of the above scenarios.

Build vs. Buy

Build vs. Buy

Brian shared with us the Microsoft blueprint for distributed architecture.

Architectural Blueprints

Architectural Blueprints

Take a look at the presentation to understand the available permeations and how your business needs map to the available architectures. Then decompose one of your systems or business processes and map to a specific architecture. Rinse and repeat with two or three more systems/processes. Finally settle on the three or four architectures that your organization will support and work within those parameters from a governance structure. From a reference perspective, the presentation will also map the logical architecture to the Microsoft product line.

Brian also covered Zermatt in session 2. Zermatt is the MS framework for implementing claims-based identity management. Unfortunately I had to attend a real work meeting, so I had to cut out early. You can find both presentations at the presentation link above.

- Andy

11
Oct

October ART – Squeak

Pushing the envelope as usual, this month’s Agile Round Table broke some new ground. But new ground is not unusual here, so maybe it’s just broke ground. While cyclical, with the latest toolset being Rails, between macro cycles the group explores and experiments with other technology. Of note lately have been the deep dives into Javascript and exploring its native OO capabilities. Last week the group wrote an implementation that created triangles in a smalltalk web app framework from Seaside called Squeak.

Now I’m not going to pretend that I understood it all. In fact, I spent the first half of the day at ArcReady, the second half at this quarter’s MSDN Event, so by the third half I was basically spent and didn’t have much left. Still, the subject matter is fascinating, and it’s such a growth experience to spend time around folks who don’t like to be comfortable within a skill set.

What I did gather, if I caught it all correctly, is that we were writing code in a browser-based development environment. The usual crowd was in attendance: @dougalcorn, @jimweirich, @esumerfd, @objwind, and others. So here are the links. If you have an evening, give Squeak a try.

Seaside Homepage

Seaside Image Download

Seaside Tutorials

Silent Seaside screen cast and here

and transcription

Steve Wessels has a tutorial and here

Squeak documentation

Resources

Seaside Book

Installing the GemStone/S Web Edition on Mac OS X Leopard

- Andy

06
Oct

Connecting Apache to Multiple Tomcat Instances on Windows

I had to configure a Windows server with Apache, Tomcat, and MySQL in order to host a number of Clearspace instances. Each instance resides on its own subdomain. For instance, we have one Clearspace instance on cma.somedomain.com and another on cts.somedomain.com. I also had the requirement to make each Tomcat instance easily identifiable in the process list.

For this installation I grabbed

  • Apache 2.2.9
  • Tomcat 6.0.16
  • mod_jk 1.2.26
  • MySQL Java connector 5.1.6

The J2sdk 1.6.0_07 had already been loaded on the machine. Here is a reason to load the SDK instead of the JRE. The JAVA_HOME environment variable is required to start Tomcat, so add the entry and point it to the root of your Java install, i.e. C:\Program Files\Java\jdk1.6.0_06.

First, I installed MySQL 5.x on the server. No issues there. I used the Windows installer with MySQL running as a service.

On to Tomcat. Tomcat can host multiple instances of itself under one install. As one of my requirements was to make each instance appear as a separate and uniquely named process I chose to install separate complete instances of Tomcat. To identify the different Tomcat installation directories create a directory for each instance with the naming convention X:\tomcat-subdomain.

Tomcat Directory Structure

Tomcat Directory Structure

Copy the MySQL Java connector into tomcat\lib.

MySQL Java Connector

MySQL Java Connector

Next setup a CATALINA_HOME environment variable for each instance of Tomcat. Point the variable to the root of the directory just created. The naming convention I used is CATALINA_HOME_SUBDOMAIN.

Tomcat Environment Variables

Tomcat Environment Variables

Each Tomcat instance will need to use a unique set of ports to communicate. Modify X:\tomcat-installdir\conf\server.xml to set the ports. You’ll want each server to listen on its own port, so modify the server port accordingly. I incremented ports by 100 where possible for each instance, so my first instance runs on port 8005, my second instance runs on 8105, etc.

Tomcat Server Port

Tomcat Server Port

Tomcat contains its own web server, so modify the HTTP port.

Tomcat HTTP Port

Tomcat HTTP Port

And most importantly, the AJP port. The AJP port is the Apache port for forwarding requests. This port will ensure that Apache and Tomcat can talk to each other.

Tomcat AJP Port

Tomcat AJP Port

Next, modify the bat files so they refer to the current Tomcat instance. To do this, after the opening comments in each file set CATALINA_HOME to the correct HOME environment variable like this

rem
rem $Id: catalina.bat 615987 2008-01-28 18:48:10Z rjung $
rem ----------------------------------------------

set CATALINA_HOME=%CATALINA_HOME_CMA%

Do this for each instance in the following bat files in X:\tomcat-subdomain\bin\

  • catalina.bat
  • digest.bat
  • shutdown.bat
  • startup.bat
  • tool-wrapper.bat
  • version.bat

Now, make sure each instance of Tomcat appears as its own identifiable process in the process list. Rename the Tomcat EXEs to something identifiable in the process list. I followed my convention of tomcat-subdomain.

Tomcat EXEs

Tomcat EXEs

Then modify service.bat to reflect the changes. You’ll see ***MODIFY THIS LINE*** where you need to make modifications.

@echo off
if "%OS%" == "Windows_NT" setlocal

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
set CATALINA_HOME=%CATALINA_HOME_CMA%
rem ********************

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%cd%

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
if exist "%CATALINA_HOME%\bin\tomcat-cma.exe" goto okHome
rem ********************

rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd%
:gotHome

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
if exist "%CATALINA_HOME%\bin\tomcat-cma.exe" goto okHome
rem ********************

echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
set EXECUTABLE=%CATALINA_HOME%\bin\tomcat-cma.exe
rem ********************

rem Set default Service name

rem ********************
rem ***MODIFY THESE LINES***
rem ********************
set SERVICE_NAME=TomcatCMA
set PR_DISPLAYNAME=Apache Tomcat CMA
rem ********************

if "%1" == "" goto displayUsage
if "%2" == "" goto setServiceName
set SERVICE_NAME=%2

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
set PR_DISPLAYNAME=Apache Tomcat CMA
rem ********************

:setServiceName
if %1 == install goto doInstall
if %1 == remove goto doRemove
if %1 == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:    %CATALINA_HOME%
echo Using CATALINA_BASE:    %CATALINA_BASE%
echo Using JAVA_HOME:        %JAVA_HOME%

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
set PR_DESCRIPTION=Apache Tomcat Server CMA - http://tomcat.apache.org/
rem ********************

set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar
rem Set the server jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\jre\bin\client\jvm.dll
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto
:foundJvm
echo Using JVM:              %PR_JVM%
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
rem Clear the environment variables. They are not needed any more.

rem ********************
rem ***MODIFY THIS LINE***
rem ********************
set PR_DISPLAYNAME=Apache Tomcat CMA
rem ********************

set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%

Next,  modify X:\tomcat-subdomain\conf\tomcat-users.xml to add the manager credentials.

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager"/>
  <user username="tomcat" password="securePa$$word" roles="manager"/>
</tomcat-users>

Now run service.bat to install this instance of Tomcat as a service.

x:\tomcat-subdomain\bin\service.bat

Open Windows services and modify the service to run automatically.

Tomcat Services

Tomcat Services

Start your Tomcat service. Each instance of Tomcat should serve files now. You can test this by navigating to Tomcat on the open port like http://somedomain:8180. Each Tomcat instance is easily identifiable in the server’s process list.

Tomcat Process List

Tomcat Process List

Next, I installed Apache 2.2.9 using the windows installer. This was pretty straightforward. Now to configure Apache to communicate with Tomcat.

Rename mod_jk-1.2.26-httpd-2.2.4.so to mod_jk.so and copy it into the Apache modules directory.

Apache mod_jk

Apache mod_jk

Modify httpd.conf to recognize mod_jk.

Apache httpd.conf

Apache httpd.conf

Add a line to load mod_jk in the modules section.

LoadModule jk_module modules/mod_jk.so

Now configure mod_jk to work with Tomcat. Mod_jk requires a workers.properties configuration file that defines how Apache should communicate with each Tomcat worker. Right after the mod_jk LoadModule line in httpd.conf, add a line to tell Apache where to find workers.properties. I also found logging mod_jk output helpful when debugging issues. I added lines to configure logging.

JkWorkersFile conf/workers.properties
JkLogFile "C:/Apache/logs/mod_jk.log"
JkLogLevel info

workers.properties looks something like this

worker.list = cts,cma,lucrumtesting

# cts worker
worker.cts.type=ajp13
worker.cts.host=localhost
worker.cts.port=8209

# cma worker
worker.cma.type=ajp13
worker.cma.host=localhost
worker.cma.port=8409

# lucrumtesting worker
worker.lucrumtesting.type=ajp13
worker.lucrumtesting.host=localhost
worker.lucrumtesting.port=8309

The first line in workers.properties is the worker.list. The worker.list is a comma-separated list that defines which workers Apache should pay attention to. You may have additional worker configurations in the workers.properties file that do not appear in worker.list. These additional workers are ignored. Apache only uses the workers identified in the worker.list.

The remaining values tell Apache to use AJP to connect to the Tomcat instance along with the servername and the AJP port we defined in the Tomcat server.xml files earlier.

Finally, Apache needs to know about each Tomcat instance. We accomplished this by configuring a virtual host for each Tomcat instance.

    ServerName cts.lucrumclearspace.com
    JkMount /* cts

    ServerName cma.lucrumclearspace.com
    JkMount /* cma

    ServerName lucrumtesting.lucrumclearspace.com
    JkMount /* lucrumtesting

JkMount tells Apache how to map to each Tomcat worker instance as an Apache virtual host.

That’s it in terms of getting the configuration working. One final step included a redirect as I could not resolve, say, cma.somedomain. My browser continued to redirect to cma.somedomain/cma. We replaced the Tomcat default document with a redirect to cma.somedomain, and we were done.

I am not a Java app server expert by any means, so please feel free to comment if there are better ways to accomplish some of this. I’m guessing that my redirect is a kludge that someone could recommend alternatives to.

- Andy