Railo 3.x comes with BlazeDS 3.2, the Adobe open source amf engine to communicate from a Flex application to a Java backend. But we may need to modify some tomcat configurations files to get it work.  You need to verify that tomcat configurations files are properly configured for flex or not. The following are the settings needed for Flex  services:-

#1. Updating the web.xml file

/opt/railo/tomcat/conf/web.xml

Uncomment the following settings in the web.xml if present or add the following details.

<!– Load the MessageBrokerServlet  –>
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<init-param>
<param-name>messageBrokerId</param-name>
<param-value>MessageBroker</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!– The mappings for the Flex servlet –>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
/flex2gateway/*
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
/flashservices/gateway/*
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
/messagebroker/*
</servlet-mapping>

#2. Updating the uriworkermap.properties file

/opt/railo/tomcat/conf/uriworkermap.properties

Add the following details.

/*.cfm=ajp13
/*.cfc=ajp13
/*.cfml=ajp13
/*.cfres=ajp13
/*.cfchart=ajp13
/*.cfm/*=ajp13
/*.cfml/*=ajp13
/*.cfc/*=ajp13
/*.jsp=ajp13
/*.do=ajp13
/=ajp13
/flex2gateway/*=ajp13
/flashservices/gateway/*=ajp13
/messagebroker/*=ajp13
/=ajp13

Once you’ve updated Tomcat configuration files, restart Tomcat/Railo.

Verify the Flex

Browse to  http:///flex2gateway/  you should get a white page, if you get an error message, this would mean that either you server is not running, the MessageBroker Servlet is not running or there are some configuration mistakes.

Troubleshooting 404 error

Apache 404 error

1.Please understand that if the URL you’re using is this: http://mydomain/flex2gateway , then all your mappings should look like
/flex2gateway*=ajp13
There must no trailing slash on either of them.

2.Also verify the server.xml is updated correctly and hence the domain is  pointing to its  webroot.

3. Most importantly, the mod_jk module needed to be loaded in to apache, then only the connection between tomcat and apache works. So please verify the apache configurations files and verify the mod_jk is enabled. If not add the following details to the apache configuration file.

<IfModule !mod_jk.c>
LoadModule jk_module [modules directory]/mod_jk.so
<!–IfModule>

<IfModule mod_jk.c>
JkMount /*.cfm ajp13
JkMount /*.cfc ajp13
JkMount /*.do ajp13
JkMount /*.jsp ajp13
JkMount /*.cfchart ajp13
JkMount /*.cfm/* ajp13
JkMount /*.cfml/* ajp13
Flex Gateway Mappings
# JkMount /flex2gateway/* ajp13
JkMount /flashservices/gateway/* ajp13
JkMount /messagebroker/* ajp13
JkMountCopy all
JkLogFile [log directory]/mod_jk.log
</IfModule>

ps: Please restart the httpd service.

Tomcat 404 error

The reason mostly is Tomcat servlet “MessageBrokerServlet” is unavailable or not loaded. In that case please verify the tomcat configuration files are updated correctly as mentioned above, ie web.xml and uriworkermap.properties files. Also verify tomcat log files to find out why “MessageBrokerServlet” is not loaded. Sometimes you may need to comment “MessageBrokerServlet” in other web.xml files.

Tomcat log file location:- /opt/railo/tomcat/logs/

ps: You need to restart railo/tomcat if you made any changes to tomcat configuration files.