Quantcast

Grails data mapping plugin configuration problems

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails data mapping plugin configuration problems

barnesjd
I'm attempting to write my own datastore and package it up as a plugin.  I've been following the Reference Documentation.  I have the project setup where I can run the tests (none of the pass yet, of course), install it, package it as a plugin, and add the plugin to an application.  My low-level API implementation is basically just a bunch of stubs at this point to convince myself that I sorta know what I'm doing.  So far, all of that has been a success.

However, I am struggling to get this plugin to load into an application.  I know it won't really work yet, but I would just like to see that my data store implementation was correctly packaged into a plugin.  In particular, it seems that I'm failing to register my datastore bean.  Whenever I run my dynamic methods configurator, it's hitting a null pointer exception for my datastore.

I think that my code should be registering this bean.  As you can see below, in my plugin groovy class, I am returning my configurator's getConfiguration() closure.  Then in the configurer, I am registering my shireDatastore.  I've gotten to this point by mimicking what I've seen in the neo4j and jpa plugins but I'm definitely missing something.  Any help will be greatly appreciated.

From ShireGrailsPlugin:
    def doWithSpring = new ShireSpringConfigurer().getConfiguration()

From ShireSpringConfigurer:
    public Closure getSpringCustomizer() {
        return {
            shireMappingContext(ShireMappingContextFactoryBean) {
                grailsApplication = ref('grailsApplication')
                pluginManager = ref('pluginManager')
            }

            shireDatastore(ShireDatastoreFactoryBean) {
                mappingContext = shireMappingContext
            }
        }
    }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
No ideas anyone?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
After some debugging, I have discovered that the SpringCustomizer closure is NEVER called.  I see where it is being returned, but neither it nor the closure returned by SpringConfigurer.configureSpring().

So... how do I get the plugin to have its customizer called?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

Graeme Rocher-4
Administrator
Sorry for the late reply, just got back from vacation.

In your plugin you need to have something like:

    def doWithSpring = new MongoSpringConfigurer().getConfiguration()

MongoSpringConfigurer in this case is a subclass of SpringConfigurer,
you'll want your own implementation of course

Do you have this?

Cheers

On Fri, Aug 24, 2012 at 4:30 AM, barnesjd <[hidden email]> wrote:

> After some debugging, I have discovered that the SpringCustomizer closure is
> NEVER called.  I see where it is being returned, but neither it nor the
> closure returned by SpringConfigurer.configureSpring().
>
> So... how do I get the plugin to have its customizer called?
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Grails-data-mapping-plugin-configuration-problems-tp4633544p4633679.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
Thanks for the reply!  I certainly have that in my code:

    def doWithSpring = new ShireSpringConfigurer().getConfiguration()

...where ShireSPringConfigurer subclasses SpringConfigurer.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
Any ideas why this isn't getting called?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

sergiomichels
If you change that to do directly in the  ShireGrailsPlugin it works?


On Tue, Aug 28, 2012 at 2:42 PM, barnesjd <[hidden email]> wrote:
Any ideas why this isn't getting called?



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-data-mapping-plugin-configuration-problems-tp4633544p4633908.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

Graeme Rocher-4
Administrator
In reply to this post by barnesjd
It should be getting called, can't spot anything immediately obvious.
Is you code available anywhere to try?

Cheers

On Tue, Aug 28, 2012 at 7:42 PM, barnesjd <[hidden email]> wrote:

> Any ideas why this isn't getting called?
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Grails-data-mapping-plugin-configuration-problems-tp4633544p4633908.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
In reply to this post by sergiomichels
I haven't tried that, but I'll give it a shot when I get a chance.  

Graeme, I do not currently have this code in a repository that you could access.  I may drop it off in BitBucket if I can't figure it out.

Thanks guys!
Joe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
Well, I have another problem with this plugin, so I'll just add it to this thread since it's related.  I was able to run my test suite at one time, and I've done something that has broken it.  I've not been able to figure out what to roll back to get me back in a good state.  Every time my tests attempt a GORM operation, I get this exception from the DatastoreUtils:

java.lang.IllegalStateException: No Datastore Session bound to thread, and configuration does not allow creation of non-transactional one here
	at org.grails.datastore.mapping.core.DatastoreUtils.doGetSession(DatastoreUtils.java:148)
	at org.grails.datastore.mapping.core.AbstractDatastore.getCurrentSession(AbstractDatastore.java:104)
	at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:299)
	at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:34)
	at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:142)
	at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:102)
	at org.grails.datastore.gorm.InstanceMethodInvokingClosure.call(GormEnhancer.groovy:258)
	at grails.gorm.tests.CrudOperationsSpec.Test basic CRUD operations(CrudOperationsSpec.groovy:45)

Any ideas what causes this error?

Thanks,
Joe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
I've figured out why I'm getting this error.  It's because my Session constructor is attempting to connect to my back end data source, but it is excepting out.  I never knew because the stack trace isn't getting printed to the console.  Do any of you know where standard error ends up when running these tests with gradle?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
And I have again found the answer to my own question.  The build/test-results xml files contain both standard out and standard error.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails data mapping plugin configuration problems

barnesjd
Well I finally figured out my original problem.  Turns out I was doing something dumb.  I had forgotten that package-plugin produces a zip file, but I have to manually unzip it to a directory so my application can pull it in.

A facepalm emoticon would be good here...
Loading...