Expand my Community achievements bar.

SOLVED

FDS Instantiation Error

Avatar

Level 1
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.





1 Accepted Solution

Avatar

Correct answer by
Level 1
I finally got my application to run! The problem was that I
had been compiling the Java classes as a General Application using
NetBeans 5. When I switched over to a Web Application Project the
classes were executable/callable by the Data Service thread.

View solution in original post

4 Replies

Avatar

Level 3
Your process "looks" correct.



I assume your package header for your java classes is

[code]package samples.twa;[/code]



Also have you written a java test class that excercises your
java code to make sure that is working properly? Sorry - have to
ask!

Avatar

Level 1
First of all - Thank you for responding to my post!



yes the package header is package samples.twa;



I have not written a test class for the java code yet. I will
do that and update my post.

Again thank you for your response!

Avatar

Level 1
I created a test program for Java code and it successfully
calls the loadPersons method. I copied the class files from this
test program's build\classes directory to classes\twa directory and
tried unsuccessfully to start Data Service destination person.



I am building my java code in NetBeans 5.0 . Is there a
certain type of project template that needs to be used to make the
class files executalbe by the Data Service thread. I noticed that
in the contact example's ContactAssembler class that there is no
main and no constructor for ContactAssembler



Should I be putting these classes in a jar file? If yes what
file do I modify to add the jar file to the class-path of the Data
Service thread?

Avatar

Correct answer by
Level 1
I finally got my application to run! The problem was that I
had been compiling the Java classes as a General Application using
NetBeans 5. When I switched over to a Web Application Project the
classes were executable/callable by the Data Service thread.