Friday, December 9, 2011

Prevent Railo's Default FLEX Integration From Generating WEB-INF Directories in Every Web Subdirectory

I recently upgraded to a new AWS server and started from scratch with Apache + Tomcat + Railo 3.3. This comes with a short vertical learning curve in regards to learning Tomcat set-up woes and new railo server.xml default settings. The last of which was the biggest surprise and confusingly new issue until I learned how easy it was to resolve.

New Railo installs, by default, are set up to integrate with FLEX. This should either be an option during installation, or... it should be an option during installation. I had never used the new railo-...-installer.run program, I really liked it a lot, but I really wish it had asked me if I wanted FLEX integration in the process. It's a small thing, but it's always the smallest things that make the biggest difference. It's okay, I'm still a [Railo] believer.

So, to fix this issue, go to the bottom of /opt/railo/lib/railo-server/context/railo-server.xml (or where ever you have your Railo engine installed)

Change:
<flex configuration="xml"/>

To:
<flex configuration="manual"/>

Then you cango to your website root directory and run:
$ ls -alR | grep 'WEB-INF'


That will show all of the 'WEB-INF' directories that you don't need (in your /images, /css, /js, ...) that you should delete with following command:
$ sudo rm -RIf ./css/WEB-INF
$ sudo rm -RIf ./images/WEB-INF
$ sudo rm -RIf ./js/WEB-INF
... etc., etc.


Notes on the above: the 'R' = recursive, the 'I' (capital i, not lowercase L) ignores errors, and the 'f'' means 'force' to ignore 'are you sure' confirmation questions.

Then you can go into the Railo SERVER admin and Restart the server there, or recycle Tomcat and that will regenerate the one and only required 'WEB-INF' in the web root directory.


- UPDATE -
It turns out the above was not the only issue, as it was not completely resolved. After a lot more testing I found that I had also incorrectly set up my Tomcat Virtual Hosts. On this Ubuntu Railo-Tomcat server the Tomcat server.xml is located in /opt/railo/tomcat/conf/server.xml. My site's host xml was not set up correctly - missing the attribute 'autoDeploy' in conjunction with having an unwanted 'appBase' attribute. (See the first and second wrong ways below.)

My first WRING way:
<host name="www.website1.com" appbase="/var/www/website1">
<context path="" docbase="">
...
</host>


My Second WRONG way:
<host name="www.website1.com" appbase="/var/www" autoDeploy="false">
<context path="" docbase="website1">
...
</host>

// this actually worked, but we don't need appBase at all for CFM. the reason the first attempt above was screwing things up is that not setting 'autoDeploy' at all defaulted to 'true'. Setting it to false fixed the WEB-INF in the sub-directories, but it's still not right.

Here is the RIGHT way:
<host name="www.website1.com">
<context path="" docbase="/var/www/website1">
...
</host>



That's today's lesson learned.

No comments: