views:

36

answers:

1

I am creating an application with google app engine and grails. I have a Controller set up for my Flex application to call. The Controller calls a service to get a list back and send it back to Flex.

The Flex client is able to get the data back one time. Also If I call the action in the browser I can call the action and get data back as well. The problem that I am finding is that it is not able to call it more than once because the app is using JDO and after the first call I get an error saying that the persistenceManager has been closed.

I have read some posts that show you how to set up a single ton and just get an instance of the persistanceManager when you need it but this does not seem to work either.

This is my first time working with JDO and I could use some advice one getting these services to work on a consistant bases.

Here is the code from the service that is actually querying the datastore.

package com.dlish.fulcrum

import com.dlish.fulcrum.PMF
import org.springframework.beans.factory.InitializingBean
import com.google.appengine.api.datastore.*
import com.dlish.fulcrum.Show

class VenueBlastService {

    static transactional = true

    def grailsApplication
    def setting

    void afterPropertiesSet()
    {
        this.setting = grailsApplication.config.setting
    }

    def persistenceManager

    def getAllShows() {         

        def query = persistenceManager.newQuery( Show )
        def  showInstanceList = query.execute()

        return showInstanceList

    }
}
A: 

This is very similar to my Controller's code. Except I don't use the transactional = true, why do you want this you're only doing a read? What version of the app-engine plugin are you using?

Here's my jdoconfig.xml:

<?xml version="1.0" encoding="utf-8"?>

<persistence-manager-factory name="transactions-optional">
    <property name="javax.jdo.PersistenceManagerFactoryClass"
        value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
    <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
    <property name="javax.jdo.option.NontransactionalRead" value="true"/>
    <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
    <property name="javax.jdo.option.RetainValues" value="true"/>
    <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
</persistence-manager-factory>

ballmw