문제

I have created a Grails-based web application and it crashes on startup if I attempt to save anything in the BootStrap.groovy file. If I comment out all of the save() statements in the BootStrap.groovy file then the application starts and all of the tables are created successfully.

Here is my BootStrap.groovy file:

class BootStrap
{
    def init = { ServletContext context ->

        // Register Custom Object Marshallers
        WebApplicationContextUtils.getWebApplicationContext(context).getBean("customObjectMarshallers").register()


        // Contact Type Tags
        [
            [ tag: "preferred" ],
            [ tag: "default" ],
            [ tag: "mobile" ],
            [ tag: "cell" ],
            [ tag: "work" ],
            [ tag: "home" ],
        ].each {
            def type = TypeTag.findByTag(it.tag)
            if(!type) {
                TypeTag tag = new TypeTag(tag: it.tag)
                tag.validate()
                tag.save()

                def foo = "bar"
            }
        }
    }

And this is what happens in the log:

Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Error 2014-03-19 18:47:41,439 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: null
Message: null
    Line | Method
->>  423 | initMetaDataColumnIndexes        in oracle.jdbc.driver.AutoKeyInfo
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    396 | initMetaData                     in     ''
|     77 | getMetaData . . . . . . . . . .  in oracle.jdbc.driver.OracleReturnResultSet
|     39 | doCall                           in BootStrap$_closure1_closure3
|     27 | doCall . . . . . . . . . . . . . in BootStrap$_closure1
|    308 | evaluateEnvironmentSpecificBlock in grails.util.Environment
|    301 | executeForEnvironment . . . . .  in     ''
|    277 | executeForCurrentEnvironment     in     ''
|    262 | run . . . . . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1145 | runWorker                        in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run                              in java.lang.Thread
Disconnected from the target VM, address: '127.0.0.1:60455', transport: 'socket'

In the BootStrap.groovy file, line 39 is the tag.save() statement. If I comment the line then the application starts just fine. The tag.validate() line executes fine and there are no errors in the object at that point.

I am running Java 1.7 update 45 and Grails 2.3.7. I updated the grails-hibernate plugin to 3.6.10.10. I also have the ojdbc7.jar file in the lib folder. Oracle version is 11gR2.

Any help is much appreciated.

도움이 되었습니까?

해결책

It looks like your driver may be the problem: See here: Similar document problem

It looks like for some reason there is an issue with some versions of the drivers and the auto increment columns.

I'd try a different version of the driver and see if you have any luck.

Hope that helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top