We are trying to decide if we want to go with Adobe Flex,
Flex Data Services and ColdFusion. We are mostly interested in Flex
Data Services push capabilities. We need to be very nimble and have
the ability to make rapid website changes. Currently, I am
evaluating these tools but often run into difficulty getting simple
things to work. I am having trouble learning to use Java objects
with Flex Data Services. I have run through a range of problems
from failing to connect to an rtmp channel to failing to
instansiate a Java object. It seems like everything thing I try
leads to new problems.
I am trying to run Flex Data Services on Tomcat (if that
makes a difference), jdk 1.5.0_09 and trying to get a very simple
mxml script to talk to very simple Java objects.
The mxml is simple:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"> <mx:ArrayCollection id="myData2"/>
<mx:DataService id="RRA" destination="RRA"/>
<mx:DataGrid
dataProvider="{ myData2 }"
<mx:columns>
<mx:DataGridColumn
headerText="Name"
dataField="name"
width="60" />
</mx:columns>
</mx:DataGrid>
<mx:Button label="go" click="RRA.fill(myData2)"
/>
</mx:Application>
The flex-enterprise services.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include
file-path="flex-remoting-service.xml" />
<service-include file-path="flex-proxy-service.xml"
/>
<service-include file-path="flex-message-service.xml"
/>
<service-include file-path="flex-data-service.xml"
/>
</services>
<security>
<login-command
class="flex.messaging.security.JRunLoginCommand"
server="JRun"/>
<security-constraint id="basic-read-access">
<auth-method>Basic</auth-method>
<roles>
<role>guests</role>
<role>accountants</role>
<role>employees</role>
<role>managers</role>
</roles>
</security-constraint>
</security>
<channels>
<channel-definition id="my-amf"
class="mx.messaging.channels.AMFChannel">
<endpoint uri="
http://{server.name}:{server.port}/{context.root}/messagebroker/amf"class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
<channel-definition id="my-rtmp"
class="mx.messaging.channels.RTMPChannel">
<endpoint uri="rtmp://{server.name}:2038"
class="flex.messaging.endpoints.RTMPEndpoint"/>
<properties>
<idle-timeout-minutes>20</idle-timeout-minutes>
<client-to-server-maxbps>100K</client-to-server-maxbps>
<server-to-client-maxbps>100K</server-to-client-maxbps>
</properties>
</channel-definition>
<logging>
<target class="flex.messaging.log.ConsoleTarget"
level="Error">
<properties>
<prefix>[Flex] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging>
<system>
</system>
</services-config>
flex-remoting-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<destination adapter="java-object" id="RO">
<properties>
<source>blah.myPackage.ATestClass</source>
<scope>session</scope>
</properties>
</destination>
</service>
flex-data-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
<service id="data-service"
class="flex.data.DataService"
messageTypes="flex.data.messages.DataMessage">
<adapters>
<adapter-definition id="actionscript"
class="flex.data.adapters.ASObjectAdapter" default="true"/>
<adapter-definition id="java-dao"
class="flex.data.adapters.JavaAdapter"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<destination id="RRA">
<adapter ref="java-dao" />
<properties>
<source>blah.myPackage.RRA</source>
<metadata>
<identity property="name"/>
</metadata>
<network>
<session-timeout>20</session-timeout>
<paging enabled="false" pageSize="10" />
<throttle-inbound policy="ERROR"
max-frequency="500"/>
<throttle-outbound policy="REPLACE"
max-frequency="500"/>
</network>
</properties>
</destination>
</service>
The destination id="RO" in flex-remoting-service.xml works OK
using <mx:RemoteObject> tag.
When trying to access the RRA object I initially had connect
failed errors when I used a channel definition that was something
like <endpoint uri="rtmp://{server.name}:{server.port}"
class="flex.messaging.endpoints.RTMPEndpoint"/> I switched
it to <endpoint uri="rtmp://{server.name}:2038"
class="flex.messaging.endpoints.RTMPEndpoint"/> and got the
runtime error (nothing in log files on startup):
[RPC Fault faultString="Unable to create a new instance of
type 'blah.myPackage.RRA'." faultCode="Server.ResourceUnavailable"
faultDetail="Types must have a public, no arguments constructor."]
at ...
I added a public default no arguments constructor to the
RRA.java file, reompiled and now I just get a runtime error that
looks like:
[RPC Fault faultString="Unable to create a new instance of
type 'blah.myPackage.RRA'." faultCode="Server.ResourceUnavailable"
faultDetail="null"]
at ...
From this configuration can anyone see why I am having
problems and how to get this simple example working? Also, is
developing for Flex Data Services typically a cumbersome task? At
this point I'm thinking that either I am missing something
fundamental or Flex Data Services is not the solution we are
looking for. What am I missing?
Thanks for any help!