OK, let us continue this: the web.xml
<context-param>
<param-name>flex.class.path</param-name>
<param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
</context-param>
<!-- Http Flex Session attribute and binding listener
support -->
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<!-- MessageBroker Servlet -->
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-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>flex.write.path</param-name>
<param-value>/WEB-INF/flex</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>FlexMxmlServlet</servlet-name>
<display-name>MXML Processor</display-name>
<description>Servlet wrapper for the Mxml
Compiler</description>
<servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
<init-param>
<param-name>servlet.class</param-name>
<param-value>flex2.server.j2ee.MxmlServlet</param-value>
</init-param>
<init-param>
<param-name>webtier.configuration.file</param-name>
<param-value>/WEB-INF/flex/flex-webtier-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>FlexSwfServlet</servlet-name>
<display-name>SWF Retriever</display-name>
<servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
<init-param>
<param-name>servlet.class</param-name>
<param-value>flex2.server.j2ee.SwfServlet</param-value>
</init-param>
<!-- SwfServlet must be initialized after MxmlServlet
-->
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>FlexForbiddenServlet</servlet-name>
<display-name>Prevents access to *.as/*.swc
files</display-name>
<servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
<init-param>
<param-name>servlet.class</param-name>
<param-value>flex.server.j2ee.ForbiddenServlet</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>FlexInternalServlet</servlet-name>
<servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
<init-param>
<param-name>servlet.class</param-name>
<param-value>flex.server.j2ee.filemanager.FileManagerServlet</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FlexMxmlServlet</servlet-name>
<url-pattern>*.mxml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FlexSwfServlet</servlet-name>
<url-pattern>*.swf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FlexForbiddenServlet</servlet-name>
<url-pattern>*.as</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FlexForbiddenServlet</servlet-name>
<url-pattern>*.swc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FlexInternalServlet</servlet-name>
<url-pattern>/flex-internal/*</url-pattern>
</servlet-mapping>
you'll also need to place the flex folder in the WEB-INF of
your WAR. Instead the flex folder is your remote-config and
services config file. The remote-config you put the java class you
are to access and the protocol you'll use (we are using AMF here):
<default-channels>
<channel ref="my-amf"/>
<!-- <channel ref="my-http"/> -->
</default-channels>
<destination adapter="java-object" id="RO">
<properties>
<source>com.simple.example.AJavaClass</source>
<scope>session</scope>
</properties>
</destination>
You'll need to adjust your service-config to point to your
application server...
<channel-definition id="my-amf"
class="mx.messaging.channels.AMFChannel">
<endpoint uri="
http://jboss.example.simple.com:8080/prefix/messagebroker/amf"class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>true</polling-enabled>
</properties>
</channel-definition>
You may need to adjust the security on services-config
accordingly. The mxml can then look like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"> <mx:Script>
<![CDATA[
private function runRO(event:Event):void
{
RO.addExclamationPoint(text1.text);
}
private function roLoaded(evt:ResultEvent):void
{
text1.text = evt.result as String;
}
]]>
</mx:Script>
<mx:VBox x="0" y="0" percentWidth="100"
percentHeight="100">
<mx:HDividedBox
horizontalAlign="left"
percentWidth="100"
percentHeight="100"
backgroundColor="#FFFFFF">
<mx:TextInput id="text1" />
<mx:Button label="go" click="runRO" />
</mx:HDividedBox>
</mx:VBox>
<mx:RemoteObject id="RO" destination="RO" >
<mx:method
name="addExclamationPoint"
result="roLoaded(event)"
fault="mx.controls.Alert.show(event.fault.message, 'RO
Error')"/>
</mx:RemoteObject>
</mx:Application>
We then precompile the flex and place the swf in the root
directory of the war. You then just wrap it all up in the WAR and
place it on the application server. Then things just magically
work.
Unfortunately, there is no steadfast way to do this because
of the multiple platforms this needs to be able to run on. But this
is esstentially how we got ours to work. As for using it with CF if
you google "Flex 2 RemoteObject CF" you'll get plenty of examples.