Railo, Flex Remoting and HTTP Auth

On March 29, 2011, in ColdFusion, Flex, Railo, by Anuj Gakhar

I’ve got an app running on Railo which has a Flex app being used and the Flex app uses Flex Remoting to communicate with CFC’s from Railo. That has been working absolutely fine for a few weeks now , until today, when I turned on the Apache based HTTP Authentication on the entire folder. All of a sudden, the remoting calls started giving me this error :-

[xml]
java.lang.NoClassDefFoundError: flex/messaging/security/TomcatLoginHolder
flex.messaging.security.TomcatLoginCommand.doAuthentication(TomcatLoginCommand.java:42)
flex.messaging.security.LoginManager.login(LoginManager.java:200)
flex.messaging.services.AuthenticationService.decodeAndLoginWithCharset(AuthenticationService.java:131)
flex.messaging.services.AuthenticationService.decodeAndLogin(AuthenticationService.java:95)
flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:338)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[/xml]

Obviously, that is not an error that tells you a lot about what has gone wrong. After doing some reading around the web, here is the solution that finally worked for me in the end :-

  1. Download the BlazeDS Turnkey Zip file from Adobe’s website. (blazeds-turnkey-4.0.0.14931 as of this writing)
  2. Unzip the downloaded file and copy /resources/security/flex-tomcat-common.jar and /resources/security/flex-tomcat-server.jar to your tomcat’s lib directory or any other directory if you want (I copied in {tomcat_home}/lib/blazeds)
  3. Open tomcat’s configuration file catalina.properties and find common.loader and add the new jars at the end. My catalina.properties looks like this :-
    [xml]common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/lib/blazeds/*.jar

    [/xml]

  4. Add the following to tomcat’s context.xml (/opt/tomcat/conf/context.xml)
    [xml]<Valve className="flex.messaging.security.TomcatValve"/>

    [/xml]

  5. Restart Tomcat

At this point, your Flex remoting calls should work fine. It took me a good couple of hours to sort this one out, so I thought I might as well blog it.

P.S. I am assuming that you already have Railo and Tomcat running together on your server and therefore I haven’t spoken about that in this post. There are loads of posts on the web talking about that stuff so if you need help with that, please Google it 🙂

Tagged with:  

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar
%d bloggers like this: