multiple CF instances in an EAR
To continue on my series about deploying CF apps, I'm going to cover a nice method of doing multiple instances, using an EAR deployment.
You'll want to start off with your EAR folder. For this example we'll use Railo, cuz it's the best, but the others work similarly.
I'll call this EAR railo.ear. So I make a folder called railo.ear, and within it I create a folder called META-INF, and then inside that I create a file called application.xml.
Into railo.ear/META-INF/application.xml I put this:
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" "http://java.sun.com/j2ee/dtds/application_1_2.dtd">
<application id="Application_ID">
<display-name>RailoApps</display-name>
<description>Railo Applications</description>
<module id="widgets">
<web>
<web-uri>widgets.war</web-uri>
<context-root>/widgets</context-root>
</web>
</module>
<module id="sprockets">
<web>
<web-uri>sprockets.war</web-uri>
<context-root>/sprockets</context-root>
</web>
</module>
</application>
You're probably wondering what the widget and sprocket wars are. They are the names of our (in this example) Railo CF applications (widgets.com and sprockets.com).
We'll start off with a normal Railo war install. You've got WEB-INF/web.xml and a bunch of libraries in WEB-INF/libs. What we're going to do is move the {railo.war}/WEB-INF/libs folder to our EAR folder ({railo.war}/WEB-INF/libs becomes railo.ear/libs). Next we'll rename the railo.war to widgets.war, and move it under our EAR (ex.: railo.ear/widgets.war). It will be a pretty lonely folder, there's nothing in it besides WEB-INF/web.xml.
Now, I like using one web admin for all the instances (DSNs and whatnot only need to be configured once, and any CF apps in the ear will pick them up), so this is how I change the WEB-INF/web.xml file configuration param for Railo to achieve this:
This tells Railo to store it's "web" configuration information in railo.ear/META-INF/railo-web.
Next we copy the widgets.war directory to sprockets.war. That's it. (Make as many copies as you want (we're sticking to widgets and sprockets), just give them unique directory names. Each one of these will be an instance. Good thing we're using one configuration location for all of them, neh?)
I like storing the configuration with the EAR, in the future this might come in handy...
Anyways, now move that EAR into your application server's deployment directory, and fire up your container/server.
If all goes well, you should see some output about railo generating it's flex stuff and whatnot (almost all of it will end up in railo.ear/libs), and see the widgets and sprockets contexts load up.
If you really did see them load up, then you can browse to each application using a URL format like this: http://your.host.name:8080/widgets and http://your.host.name:8080/sprockets. (See, the name of the directory becomes the context name. Neat, nuh?)
Assuming that worked, you're done! (with this part... next comes hooking them up to Apache.)

There are no comments for this entry.
[Add Comment] [Subscribe to Comments]