Railo on Tomcat on Windows x64 - Part III

Now that we've got Tomcat, Railo and Apache httpd up and running, lets connect Tomcat and Apache.

For this we will need a mod_jk connector. The binary can be found here.

There is no x64 connector as there is no x64 official release of Apache httpd, so we will be using the x32 connector. In my case I downloaded mod_jk-1.2.28-httpd-2.2.3.so from the win32 folder. Download this file and put it in C:\Apache2\modules. Now rename it to mod_jk.so

Create a file in c:\Apache2\conf\extra called workers.properties and put this into the file

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

Now lets download Railo and lets set it up. We want to get the custom one, the jars, in my case "railo-3.1.2.001-jars.zip (34 MB)". Create a Railo folder in the Tomcat folder, in my case "C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0".

Now open up the railo zip file and put the jar files from the railo-3.1.2.001-jars into the railo folder we just created.

Now edit the catalina.properties file that was in Tomcat conf folder, in my case "C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\conf". Find the line that says "common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar" and edit it to say "common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/railo/*.jar"

Now open tomcat-usrs.xml and change the encoding to utf-8. At the top where it says "<?xml version='1.0' encoding='cp1252'?>" and change it to "<?xml version='1.0' encoding='utf-8'?>" This is needed due to some weird Tomcat bug on windows.

Now lets open web.xml in the Tomcat's conf directory. Just before the "Built In Servlet Mappings" add the following:

<servlet>
<servlet-name>RailoCFMLServlet</servlet-name>
<description>CFML runtime Engine</description>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>/WEB-INF/railo</param-value>
<description>Configuration directory</description>
</init-param>
<!-- init-param>
<param-name>railo-server-root</param-name>
<param-value>.</param-value>
<description>directory where railo root directory is stored</description>
</init-param -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>RailoAMFServlet</servlet-name>
<description>AMF Servlet for flash remoting</description>
<servlet-class>railo.loader.servlet.AMFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>RailoFileServlet</servlet-name>
<description>File Servlet for simple files</description>
<servlet-class>railo.loader.servlet.FileServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

Now at the end of the servlet mapping section, add the following

<servlet-mapping>
<servlet-name>RailoCFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoCFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoCFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoAMFServlet</servlet-name>
<url-pattern>/flashservices/gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<!-- could be RailoFileServlet -->
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

Now open up server.xml and at the end of the file inside the Engine tag, we'll add a new host definition.

<Host name="railotest" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="c:/websites/railotest" />
</Host>

Now lets go back to our httpd-vhosts.conf Apache file. We need to add the following (I do this outside of any virtualhost definitions.

# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/extra/workers.properties
# Where to put jk shared memory
JkShmFile logs/mod_jk.shm
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

We also need to add the following to the VirtualHost definition

# Send requests for cfm files to worker named worker1
   JkMount /*.cfm    worker1

The full virtualhost definition should look like

<VirtualHost *:80>
   DocumentRoot "C:/websites/railotest"
   ServerName railotest
   ErrorLog "logs/railotest.com-error.log"
   CustomLog "logs/railotest-access.log" common
   # Send requests for cfm files to worker named worker1
   JkMount /*.cfm    worker1
</VirtualHost>

Now if we restart Tomcat and Apache we should be able to hit http://railotest in our browser and see the debugging info. We will also see a WEB-INF folder created inside c:\websites\railotest.

Now lets put in an alias for the railo-context so that we can get to the admin. Inside the virtual host add

Alias /railo-context C:\websites\railotest\WEB-INF\railo\context

Now restart Apache and we should be able to get to the Web Administrator for this host by going to http://railotest/railo-context/admin.cfm

Railo on Tomcat on Windows x64 - Part II

In the previous two parts we installed Tomcat. Now lets set up Apache httpd server.

I suggest downloading Apache from Apache Lounge. The nice thing about Apache Lounge's builds is that they include mod_rewrite and mod_ssl.

The latest version at the time of this writing is 2.2.14. Download httpd-2.2.14-win32-x86-ssl.zip and open it in your favorite archiver (mine is WinRar).

I recommend taking the Apache2 folder inside the zip file and placing it on c:\. After you've done this you should have a c:\Apache2 folder with many files and subfolders in it.

Open c:\Apache2\conf\httpd.conf file in your favorite text editor. I recommend Textpad.

I usually change a few things from the defaults. Your configuration may differ.

Change

ServerAdmin admin@example.com
to your email address.

Uncomment the following modules:

#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule rewrite_module modules/mod_rewrite.so
by removing the # sign in front of the line.

Find the line that says

<Directory "c:/Apache2/htdocs">

After closing directory tag lets add one allowing access to our web root. I usually set up a folder or a new drive for it. Lets say we set up a webroot of "c:\websites". Create a folder websites on c: and then inside it create another folder called railotest. We will use this to set up our test site.

After the closing tag, add a new one allowing access to our web root.

<Directory "c:/websites">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

This will allow Apache to serve from anywhere inside c:\websites. Alternatively, you can set up a new directory entry for every site that you create, but I find that this makes things easier without significantly impacting security.

Find the line that says

DirectoryIndex index.html

and add index.cfm to that list

DirectoryIndex index.html index.cfm

Uncomment the line that says

#Include conf/extra/httpd-vhosts.conf
by removing the # sign.

Now open up httpd-vhosts.conf file that is located in "C:\Apache2\conf\extra".

There are two sample virtual hosts defined. Lets comment them both out. Alternatively you can just delete them.

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
should look like this:

#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error.log"
# CustomLog "logs/dummy-host.example.com-access.log" common
#</VirtualHost>
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "logs/dummy-host2.example.com-error.log"
# CustomLog "logs/dummy-host2.example.com-access.log" common
#</VirtualHost>

Now lets add a new entry for our test server

<VirtualHost *:80>
DocumentRoot "C:/websites/railotest"
ServerName railotest
ErrorLog "logs/railotest.com-error.log"
CustomLog "logs/railotest-access.log" common
</VirtualHost>

Now save the files and lets try running apache and see if it worked. Open up command prompt (Start -> Run -> cmd.exe)

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator>cd \apache2\bin

C:\Apache2\bin>httpd
httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName
We can ignore that warning since we don't care about the default configuration.

Now we will need to define a host called railotest using windows hosts file. Open up "C:\windows\system32\drivers\etc\hosts" file in your favorite text editor.

After a bunch of comments, you should see

127.0.0.1 localhost

Lets add an entry for railotest

127.0.0.1 railotest

Now this computer knows that railotest points to 127.0.0.1.

Lets put a test cfm file in the webroot for railotest. Create a new file called index.cfm and put it in c:\websites\railotest.

Inside the file lets put some basic cf code

<cfdump var="#server#">

If you still have apache running and put in http://railotest in your browser you should see the code being output. It is not being interpreted yet because we have not hooked up Apache httpd to Railo. We will do this in Part IV.

For now lets set up apache to run as a service.

First stop the httpd that you ran earlier by entering ctrl-c and do the following.

C:\Apache2\bin>httpd -k install
Installing the Apache2.2 service
The Apache2.2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName

The Apache service is now installed. I recommend also adding the "Apache Monitor" app to your startup folder.

Click Start->All Programs and right click on Startup. Now click "Explore All Users". In another explorer window open up C:\Apache2\Bin and right drag ApacheMonitor.exe to the Startup folder. Let go of the right mouse button and select "Create shortcut here".

Double click on the shortcut and the monitor App should appear in your taskbar next to the clock and next to Tomcat's icon.

Double click it to open it and click start. Now you have a working Apache installation that will start as a service.

If you enter http://railotest in your browser, you should see the code we wrote earlier. This will persist across reboots.

In the next part, we'll hook it up to Railo and be able to actually execute this code.

Railo on Tomcat on Windows x64 - Part I

I tried following Sean Corfield's excellent post on how to get Railo running on Tomcat, but ran into a few snags on my x64 windows system.

First download Tomcat 6 from the Apache Foundation. I picked the "Windows Service Installer" of the Core.

Start up the installer and hit next a few times until you get to the "Choose Components" section. Select Full install and then uncheck the Examples item as we won't be needing it.

Pick the installation folder, and the default port, and set a password for the administrator. At the next step it will ask for a path to a J2SE 5.0 JRE installation. Finding this on Sun's site is a bit of a pain, so here is a link to the J2SE 5.0 Update 22, which is the latest as of this writing.

Download it, install it and make a note of what folder it installs in. In my case it was "C:\Program Files\Java\jre1.5.0_22". This is the path I provided to Tomcat installer.

Finish the tomcat installation and you will see that the service is installed, but will not start. This is because we need the 64bit service wrapper

The only file that should be in there is tomcat6.exe. Download it and replace the one in your tomcat's installation bin folder. In my case that folder is "C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\bin".

Now if you go to "http://localhost:8080/", you should see The Tomcat default start page.

In part II, we will cover getting setting up Apache.

Windows Server 2003 SP2 with Firefox 3.5 - downloads "Cancelled"

It seems that the new versions of Firefox have started to respect the server's security policy.

I would usually use firefox to download things on a server to avoid having to deal with IE's enhanced security.

The solution is to change the Internet zone to medium instead of high. This option, however, is disabled by default if you have "Internet Explorer Enhanced Security" installed. This option can be uninstalled from the control panel "Add/Remove Programs'" Add Remove Windows Components option.

After uninstalling, restart firefox and you should be able to download again.

XenServer 5.5 - Converting Local Storage to NFS (and thereby enabling sparse provisioning)

XenServer will create sparse disks for your VMs only on NFS based volumes. If you are using ISCSI or local storage, it will fully allocate each disk. This is less of a problem when you have a thinly provisioned ISCSI volume which is also compressed (such as those provided by Nexenta/OpenSolaris), but when you have a limited amount of local storage, it's unfortunate that XenServer doesn't give you the option to create sparse disks.

Luckily, XenServer is just CentOS 5 under the hood, and we can turn the local storage into an NFS volume.

First we will need to delete the current Local Storage, which involves quite a few steps.

#lvdisplay
--- Logical volume ---
LV Name /dev/VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2/MGT
VG Name VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
LV UUID HlifV3-7B6J-rVCp-pAxP-Rc7e-viEQ-Tt819a
LV Write Access read/write
LV Status NOT available
LV Size 4.00 MB
Current LE 1
Segments 1
Allocation inherit
Read ahead sectors auto
Now we run xe pbd-list and find the one that matches our local SR.
#xe pbd-list
uuid ( RO) : e06a37a5-e1e6-4415-134e-f5ae4f7f7c17
host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
sr-uuid ( RO): fc8c8fc5-4a06-18b9-517d-f19a18e50820
device-config (MRO): location: /dev/xapi/cd
currently-attached ( RO): true


uuid ( RO) : 7a75d1b9-9aa5-d5f7-6b85-50d1175054c8
host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
sr-uuid ( RO): a6db482a-5446-3fc3-6513-6933eb9d7915
device-config (MRO): location: /dev/xapi/block
currently-attached ( RO): true


uuid ( RO) : 6c1eeeb0-3c05-fbee-4dca-e7490e007504
host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
sr-uuid ( RO): f663b0ec-56b0-72dc-d546-4e0fc9be7ef6
device-config (MRO): location: /opt/xensource/packages/iso; legacy_mode: true
currently-attached ( RO): true
uuid ( RO) : 825bc0eb-8ec9-01ab-e249-21146d66dd9a
host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
sr-uuid ( RO): 877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
device-config (MRO): device: /dev/disk/by-id/scsi-SATA_WDC_WD800JD-75M_WD-WMAM9AJ38489-part3
currently-attached ( RO): true

As we can see, it's the last one. Now we unplug it and destroy it.

#xe pbd-unplug uuid=825bc0eb-8ec9-01ab-e249-21146d66dd9a
#xe pbd-destroy uuid=825bc0eb-8ec9-01ab-e249-21146d66dd9a

Now lets destroy the storage repository attached to it. First we get a list of the repositories.

#xe sr-list
uuid ( RO) : a6db482a-5446-3fc3-6513-6933eb9d7915
name-label ( RW): Removable storage
name-description ( RW):
host ( RO): xenserver-ueyqfddq
type ( RO): udev
content-type ( RO): disk


uuid ( RO) : fc8c8fc5-4a06-18b9-517d-f19a18e50820
name-label ( RW): DVD drives
name-description ( RW): Physical DVD drives
host ( RO): xenserver-ueyqfddq
type ( RO): udev
content-type ( RO): iso


uuid ( RO) : 877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
name-label ( RW): Local storage
name-description ( RW):
host ( RO): <not in database>
type ( RO): lvm
content-type ( RO): user


uuid ( RO) : f663b0ec-56b0-72dc-d546-4e0fc9be7ef6
name-label ( RW): XenServer Tools
name-description ( RW): XenServer Tools ISOs
host ( RO): xenserver-ueyqfddq
type ( RO): iso
content-type ( RO): iso
We will delete the one called local storage.

#xe sr-forget uuid=877a1f66-59dd-b1ba-0de3-d8a753d0a0b2

At this point it will be forgotten and disappear from XenCenter.

Now, lets delete it from LVM.

#vgdisplay
--- Volume group ---
VG Name VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 66.85 GB
PE Size 4.00 MB
Total PE 17113
Alloc PE / Size 1 / 4.00 MB
Free PE / Size 17112 / 66.84 GB
VG UUID 2PJJkR-ULpa-1F6f-8H65-N22A-o11C-f0KkGa

Now lets remove it.

#vgremove VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
Do you really want to remove volume group "VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2" containing 1 logical volumes? [y/n]: y
Logical volume "MGT" successfully removed
Volume group "VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2" successfully removed

#pvdisplay
"/dev/sda3" is a new physical volume of "66.86 GB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 66.86 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ZK23c0-UvDg-A4MB-TWKi-YfNW-hWUK-uoyqdo
Now we remove the physical volume from LVM.
#pvremove /dev/sda3
Labels on physical volume "/dev/sda3" successfully wiped

Now lets create a filesystem for us to use.

mkfs.ext3 -m 0 /dev/sda3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
8765440 inodes, 17526915 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
535 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Now lets set up a folder for it and make sure it gets mounted at boot time.

#mkdir /data

#vi /etc/fstab
LABEL=root-cjfffcbq /ext3 defaults 1 1
/var/swap/swap.001swap swap defaults 0 0
none/dev/pts devpts defaults 0 0
none/dev/shm tmpfs defaults 0 0
none/proc proc defaults 0 0
none/sys sysfs defaults 0 0

We need to add our directory to automatically mount at boot time. Lets add this entry

/dev/sda3 /data ext3 defaults 1 2

This is how my file looked like at the end.

/ext3 defaults 1 1
/var/swap/swap.001swap swap defaults 0 0
none/dev/pts devpts defaults 0 0
none/dev/shm tmpfs defaults 0 0
none/proc proc defaults 0 0
none/sys sysfs defaults 0 0
/dev/sda3 /data ext3 defaults 1 2

Now lets try mounting it.

#mount /data

If you get no output, that means it probably worked.

Lets check that it mounted successfully.

#ls /data
lost+found

Now lets create our directories that we will export.

#mkdir /data/vm
#mkdir /data/iso

Lets edit the exports file.

#vi /etc/exports
The file should initially be empty. Lets add our entries.
/data/vm 127.0.0.1(rw,no_root_squash,sync)
/data/iso 127.0.0.1(ro,no_root_squash,sync)

Save the file, and now lets start the nfs and portmap services.

#service nfs start
Starting NFS services: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
#service portmap start
Starting portmap: [ OK ]

Lets make sure that the portmap and nfs services start at boot.

#chkconfig --level 345 nfs on
#chkconfig --level 345 portmap on

Lets verify that our directories are being exported.

#exportfs
/data/iso 127.0.0.1
/data/vm 127.0.0.1

Now we can add the Storage Repository. We can do it through XenCenter. Right click on the server in XenCenter, and click "New Storage Repository". Select "NFS VHD" as the type, and enter the following parameters.

Name: NFS Local Storage
Share Name: 127.0.0.1:/data/vm
Leave the checkbox on "Create a New SR" and click "Finish".

Lets add an ISO SR as well. Right click on the server in XenCenter, and click "New Storage Repository". Select "NFS ISO" as the type, and enter the following parameters.

Name: NFS Local Storage
Share Name: 127.0.0.1:/data/iso
Leave the checkbox on "Create a New SR" and click "Finish".

Now we reboot and if everything comes back up, we are done. Now when we create VMs, the Virtual Hard Disks will be allocated sparsely, and VMs created from templates, will all use the same base VHD and only store the changes in their own disk.

Jumbo Frames with XenServer 5.5

There doesn't seem to be any way to configure jumbo frames with XenServer 5.5, and I'm sure this is unsupported, but it can be done by hacking the XenServer 5.5 config files.

#vi /opt/xensource/libexec/interface-reconfigure +879

You will see something like this

f.write('"\n')
return f

We are going to add our MTU information there:

f.write('"\n')
#add MTU
f.write('MTU=9212\n');
return f

9212 is the MTU I chose, make sure you choose one that's appropriate for your network, and make sure to test it first.

This will only change the MTU on the bonded interfaces, I believe.

Webmin on OpenSolaris

After installing webmin from the package manager, you will need to run

webminsetup

to generate the appropriate config files.

locate on OpenSolaris

Solaris has an alternate version of locate, called slocate. updatedb is still called the same, just instead of locate, you would call slocate.

CentOS 5.3 on XenServer 5.5 Graphical Install

In order to do a graphical install (which lets you customize your LVM volumes) you just need to add the vnc option to the "OS Boot Parameters" when creating the VM. It should look like this:
graphical utf8 vnc

Once you start up your VM, it will go through a short text based configuration wizard, configuring your NIC and such, after which it will prompt you to log in using VNC.

Urchin 5 - Opening reports in the same window

By default Urchin 5 seems to want to open reports in a new window. This can be a little annoying. To change this, we just need to update the javascript function that gets run when you click on the "View Report" link.

vi /usr/local/urchin/htdocs/ujs/admin.js +434

You should see the following code:

mywin = window.open('',myname);

mywin.location.href = url;
mywin.focus();

We're going to comment it out and add our own code:

//mywin = window.open('',myname);

//mywin.location.href = url;
//mywin.focus();
window.location.href=url;

After clearing our cache, the reports open in the same window.

More Entries

BlogCFC was created by Raymond Camden.