Background: I tried to mimic the ‘contact’ Data
Service example but can’t get my destination to instantiate
on the server. I was able to get the contact sample working but my
customized version is dead in the water.
The error looks like this when I start up the JRUN server:
At jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
[0]flex.messaging.config.ConfigurationException: Unable to
create service’flex.data.DataService’ for
‘data-service’ due to the following error: Error
instantiating application scoped instance of type
‘samples.twa.TwaAssembler’ for destination
‘person’..
1)How can I find out why the destination ‘person’
couldn’t be instantiated by the Data Service?
2)Do the class files need to be put into an archive file? If
so where should put the archive file so that the server will see
it?
3) Did I miss something else?
The process that I followed is listed below:
1) I added the following to
samples\WEB-INF\flex\data-management-services.xml:
<destination id="person">
<adapter ref="java-dao" />
- <properties>
<source>samples.twa.TwaAssembler</source>
<scope>application</scope>
- <metadata>
<identity property="personId" />
</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>
- <server>
- <fill-method>
<name>loadPersons</name>
</fill-method>
- <fill-method>
<name>loadPersons</name>
<params>java.lang.String</params>
</fill-method>
- <sync-method>
<name>syncPersons</name>
</sync-method>
</server>
</properties>
</destination>
2. I created TwaAssembler.class , Person.class,
PersonDAO.class, DAOException.class ConnectionHelper.class,
ConcurrencyException.class, and ValidationException.class and put
them in the samples\WEB-INF\classes\samples\twa folder.
3. I created a Person.as file and put in the
samples\twa\samples\twa folder and I also put it in the
samples\dataservice\twa\samples\twa folder.
4. I created a Flex twa.mxml file that defines the Binding of
a Grid object to the Data Service.
<?xml version="1.0" encoding="utf-8" ?>
- <mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"creationComplete="initApp();">
- <mx:Script>
- <![CDATA[
import mx.data.DataService;
import mx.collections.ArrayCollection;
import samples.twa.Person;
public var ds:DataService;
[Bindable]
public var persons:ArrayCollection;
public var person:Person;
public function initApp():void {
persons = new ArrayCollection();
ds = new DataService("person");
ds.fill(persons);
}
]]>
</mx:Script>
- <mx:DataGrid id="dg" dataProvider="{persons}"
editable="true">
- <mx:columns>
<mx:DataGridColumn dataField="PersonId" headerText="Id"
editable="false" /> etc...
5. I created a hsqldb ‘twa’ database with a
‘Person’ table for the java-dao to query and put it in
the samples\WEB-INF\db\twa folder.