grails-spring-batch icon indicating copy to clipboard operation
grails-spring-batch copied to clipboard

Error when loading tables for Postgresql

Open john-london opened this issue 9 years ago • 3 comments

If the database type is not specified as 'postgres' (i.e. you specify postgresql as per the documentation) then you get an exception:

Error Error running forked test-app: Error creating bean with name 'jobOperator': Cannot resolve reference to bean 'jobRepository' while setting bean property 'jobRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'postgresql' is an unsupported database type. The supported database types are DERBY,DB2,DB2ZOS,HSQL,SQLSERVER,MYSQL,ORACLE,POSTGRES,SYBASE,H2,SQLITE

So you need to do this:

plugin { springBatch { jmx { enable = false } loadTables = true database = 'postgres' } }

However, this means that loadtables looks for the wrongly named scripts (the missing "ql" is important!):

// within SpringBatchGrailsPlugin.groovy doWithApplicationContext def script = "org/springframework/batch/core/schema-drop-${database}.sql" script = "org/springframework/batch/core/schema-${database}.sql"

john-london avatar Mar 03 '15 11:03 john-london

Work around for this: I use the Grails Database Migration Plugin.

Future Fix, introduce a translation function to convert the database type above into the String necessary to load the schema from the file.

danieldbower avatar Mar 04 '15 11:03 danieldbower

@danieldbower Sorry, I don't understand your workaround - I take it you specify postgres in order to not get the exception details above, but then how does the Migration Plugin help with the error in the script?

john-london avatar Mar 09 '15 12:03 john-london

So, instead of letting the Spring Batch Plugin populate the database schema, I manually add it to the data migration.

danieldbower avatar Mar 09 '15 13:03 danieldbower