I'm creating an AIR application using the Model Driven Development tools and hoping to make use of the offline cache. The generated value objects and services are working well when connected but I have been unable to get the cache working.
Currently I am generating custom offline adaptors for each of my Model entities and assigning them to the offlineAdapter property of each data service as follows:
_terminalService.serviceControl.autoCommit=false; _terminalService.serviceControl.autoConnect=true; _terminalService.serviceControl.fallBackToLocalFill=true; _terminalService.serviceControl.autoSaveCache=true; _terminalService.serviceControl.autoMerge=true; _terminalService.serviceControl.autoSyncEnabled=true; _terminalService.serviceControl.encryptLocalCache=false; _terminalService.serviceControl.offlineAdapter=new TerminalOfflineAdapter(); _terminalService.serviceControl.cacheID="ss-sclient-39";
When I run my application it works as anticipated but I am seeing the following error in the console log:
7/27/2010 12:21:25.677 [DEBUG] mx.data.DataStore Saving cached query: store id: ["getByMacAddress","001CC4313675"] lastWritten: Tue Jul 27 12:21:25 GMT+0100 2010 lastAccessed: Tue Jul 27 12:21:25 GMT+0100 2010 created: Tue Jul 27 12:21:25 GMT+0100 2010 metadata: (null) type: 1 referenced ids: ["common.Terminal:#:13"] 7/27/2010 12:21:25.677 [DEBUG] mx.data.LSODataStore dbStore lock released: 965366152 7/27/2010 12:21:25.677 [ERROR] mx.data.DataStore Error occurred saving the cache: TypeError: Error #1009: Cannot access a property or method of a null object reference. stack: TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.data.offline::EntityManager/save()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\offline\EntityManager.as:104] at mx.data.offline::EntityManager/update()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\offline\EntityManager.as:345] at mx.data::SQLiteOfflineAdapter/updateOfflineItems()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\SQLiteOfflineAdapter.as:120] at mx.data::DataStore/persistCacheItems()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:4543] at mx.data::DataStore/persistDataService()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:4679] at mx.data::DataStore/doSaveCache()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:3755] at Function/()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:3711] at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::saveCache()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:3727] at mx.data::DataList/http://www.adobe.com/2006/flex/mx/internal::processSequenceResult()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataList.as:3063] at mx.data::DataListRequestResponder/result()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataListRequestResponder.as:103] at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84] at NetConnectionMessageResponder/resultHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:547]
If I then disconnect from the server and attempt to run my client again I get the following error:
7/27/2010 12:27:46.548 [DEBUG] mx.data.DataService.common.Terminal DataService.fill() called for destination: common.Terminal with args: ["getByMacAddress","001CC4313675"] includesProperties: (include default - excludes: []) 7/27/2010 12:27:46.548 [INFO] mx.messaging.Producer 'ds-producer-common.Terminal' producer sending message 'EF832901-F3A4-7AE3-EF12-13A8897408CC' TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.data.offline::EntityManager/executeSelectQuery()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\offline\EntityManager.as:446] at mx.data.offline::EntityManager/executeQuery()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\offline\EntityManager.as:432] at mx.data::SQLiteOfflineAdapter/internalExecuteOfflineQuery()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\SQLiteOfflineAdapter.as:318] at mx.data::SQLiteOfflineAdapter/executeOfflineQuery()[C:\depot\DataServices\trunk\frameworks\projects\airfds\src\mx\data\SQLiteOfflineAdapter.as:202] at Function/()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:1651] at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::fill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:1765] at mx.data::ConcreteDataService/internalFill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:7235] at Function/()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1317] at mx.data::ConcreteDataService/fill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1336] at mx.data::DataManager/fill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataManager.as:1560] at _Super_TerminalService/getByMacAddress()[C:\Documents and Settings\benp.NB\My Documents\src\qms\workspace\CommonClient\src\common\model\_Super_TerminalService.as:226] at airclient.application::AirClientImpl/initialiseTerminalDetails()[C:\Documents and Settings\benp.NB\My Documents\src\qms\workspace\AirClient\src\airclient\application\AirClientImpl.as:146] at Function/()[C:\Documents and Settings\benp.NB\My Documents\src\qms\workspace\AirClient\src\airclient\application\AirClientImpl.as:268] at mx.collections::ItemResponder/result()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ItemResponder.as:129] at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239] at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207] at mx.data::ConcreteDataService/http://www.adobe.com/2006/flex/mx/internal::dispatchResultEvent()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:3427] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.rpc::AsyncDispatcher/timerEventHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncDispatcher.as:50] at flash.utils::Timer/_timerDispatch() at flash.utils::Timer/tick()
I'm slightly confused by the fact that the offline adaptors are derived from SQLiteOfflineAdapter and are being run within an AIR application but I am still seeing references to the LSODataStore in the logs (which I thought was only used for Flash applications). Also if I attempt to set encryptLocalCache to true I get the following error:
7/27/2010 12:32:10.409 [DEBUG] mx.data.DataStore Adding data service: common.Terminal to the data store: my-rtmp:true initialized: false Error: Encryption is not supported for local shared objects. at mx.data::LSODatabase/set encryptLocalCache()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\LSODatabase.as:149] at mx.data::DataStore/set encryptLocalCache()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataStore.as:391] at mx.data::ConcreteDataService/set encryptLocalCache()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:227] at mx.data::DataManager/set encryptLocalCache()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataManager.as:392] at airclient.application::AirServiceFactory/configureService()[C:\Documents and Settings\benp.NB\My Documents\src\qms\workspace\AirClient\src\airclient\application\AirServiceFactory.as:236]
Does anyone know what's going on here?
Thanks!