2 Replies Latest reply on Nov 28, 2006 5:27 AM by

    Flex Data Services and Java Objects

      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"/>

      dataProvider="{ myData2 }"
      width="60" />
      <mx:Button label="go" click="RRA.fill(myData2)" />


      The flex-enterprise services.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <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" />
      <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>
      <security-constraint id="basic-read-access">
      <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"/>

      <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">
      <endpoint uri="rtmp://{server.name}:2038" class="flex.messaging.endpoints.RTMPEndpoint"/>

      <target class="flex.messaging.log.ConsoleTarget" level="Error">
      <prefix>[Flex] </prefix>




      <?xml version="1.0" encoding="UTF-8"?>
      <service id="remoting-service"

      <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>

      <channel ref="my-amf"/>

      <destination adapter="java-object" id="RO">


      <?xml version="1.0" encoding="UTF-8"?>
      <service id="data-service"

      <adapter-definition id="actionscript" class="flex.data.adapters.ASObjectAdapter" default="true"/>
      <adapter-definition id="java-dao" class="flex.data.adapters.JavaAdapter"/>

      <channel ref="my-amf"/>

      <destination id="RRA">
      <adapter ref="java-dao" />
      <identity property="name"/>
      <paging enabled="false" pageSize="10" />
      <throttle-inbound policy="ERROR" max-frequency="500"/>
      <throttle-outbound policy="REPLACE" max-frequency="500"/>

      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!
        • 1. Re: Flex Data Services and Java Objects
          Mete Atamel Level 1
          It's very hard to read the configuration files you posted so I can't tell if there's a problem there. It looks like a simple problem though. Did you compile blah.myPackage.RRA? It might help if you post blah.myPackage.RRA as well.
          • 2. Re: Flex Data Services and Java Objects
            Thanks for the reply. Yes, I did compile all the Java and it works OK with a simple Java program. It just will not work in a Flex application.

            The java classes are:


            package blah.myPackage;

            import java.util.List;
            import java.util.Collection;

            import flex.data.DataSyncException;
            import flex.data.assemblers.AbstractAssembler;

            class RRA extends AbstractAssembler
            public Collection fill( List fillParameters )
            RRS service = new RRS();
            return service.getSome();


            package blah.myPackage;

            import java.util.ArrayList;
            import java.util.List;
            import java.sql.*;

            import flex.EORS.*;

            class RRS
            public List getSome()
            ArrayList list = new ArrayList();
            String str = "bob";
            RR rr = new RR(str);
            return list;


            package blah.myPackage;

            class RR
            private String name;
            public RR() { }
            public RR(String name)
            this.name = name;

            public String getName()
            return this.name;

            public void setName(String name)
            this.name = name;

            I started with something that retrieved data from a database but watered it down just to try and get some kind of communication between Flex and Java.