Results 1 to 2 of 2

Thread: jdbc:initialize-database script failures? (Spring 3.0.6) H2 embedded

  1. #1
    Join Date
    Oct 2011
    Location
    Plano, TX
    Posts
    1

    Default jdbc:initialize-database script failures? (Spring 3.0.6) H2 embedded

    So I am trying to setup my embedded DB like so -
    <jdbc:initialize-database data-source="dataSource">
    <jdbc:script location="classpath:config/H2SchemaDDL.sql" />
    <jdbc:script location="classpath:config/bootstrap.sql"/>
    </jdbc:initialize-database>

    The first script creates a MESSAGE_PROCESSORS table, amongst other stuff

    CREATE TABLE MESSAGE_PROCESSORS
    (
    ID IDENTITY (1, 1),
    PROCESS_NAME VARCHAR2(32) NOT NULL,
    PROCESS_DESC VARCHAR2(128) NULL
    );

    The second script inserts some bootstrap data in this table
    INSERT INTO MESSAGE_PROCESSORS (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job');

    running my test case with a prepopulated db seems to work fine. My ddl scripts and bootstrap scripts run fine when I execute them on a standalone instance of H2

    Running my test case which initializes and loads the context gives me this error -
    Is there something missing in my init configuration?

    20:31:22,719 INFO main init.ResourceDatabasePopulator:147 - Executing SQL script from class path resource [config/H2SchemaDDL.sql]
    20:31:22,736 INFO main init.ResourceDatabasePopulator:198 - Done executing SQL script from class path resource [config/H2SchemaDDL.
    sql] in 16 ms.
    20:31:22,737 INFO main init.ResourceDatabasePopulator:147 - Executing SQL script from class path resource [config/bootstrap.sql]
    20:31:22,764 INFO main support.DefaultListableBeanFactory:422 - Destroying singletons in org.springframework.beans.factory.support.
    DefaultListableBeanFactory@326b9c84: defining beans [defaultConfiguration,org.springframework.beans.fac tory.config.PropertyPlacehold
    erConfigurer#0,testDataSource,dataSource,transacti onManager,org.springframework.aop.config.internalA utoProxyCreator,org.springframew
    ork.transaction.annotation.AnnotationTransactionAt tributeSource#0,org.springframework.transaction.in terceptor.TransactionInterceptor
    #0,org.springframework.transaction.config.internal TransactionAdvisor,org.springframework.jdbc.dataso urce.init.DataSourceInitializer#
    0,msgStoreService,org.springframework.context.anno tation.internalConfigurationAnnotationProcessor,or g.springframework.context.annota
    tion.internalAutowiredAnnotationProcessor,org.spri ngframework.context.annotation.internalRequiredAnn otationProcessor,org.springframe
    work.context.annotation.internalCommonAnnotationPr ocessor]; root of factory hierarchy
    20:31:22,768 ERROR main context.TestContextManager:324 - Caught exception while allowing TestExecutionListener [org.springframework.
    test.context.support.DependencyInjectionTestExecut ionListener@31a3ca10] to prepare test instance [com.gwinteg.pc.datastore.internal.
    MessageStoreServiceJdbcTest@7826f9e5]

    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.jdbc.datasource.init.DataSour ceInitializer#0': Invocation of init method failed; nested exception is org.springframework.dao.DataAccessResourceFailureE xception: Failed to populate database; nested exception is org.springframework.jdbc.datasource.init.ScriptSta tementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [config/bootstrap.sql]: INSERT INTO "MESSAGE_PROCESSORS" (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job')
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 93)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:290 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:84)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:1)
    at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:280)
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:304)
    ... 24 more
    Caused by: org.springframework.dao.DataAccessResourceFailureE xception: Failed to populate database; nested exception is org.springframework.jdbc.datasource.init.ScriptSta tementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [config/bootstrap.sql]: INSERT INTO "MESSAGE_PROCESSORS" (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job')
    at org.springframework.jdbc.datasource.init.DataSourc eInitializer.afterPropertiesSet(DataSourceInitiali zer.java:92)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
    ... 37 more
    Caused by: org.springframework.jdbc.datasource.init.ScriptSta tementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [config/bootstrap.sql]: INSERT INTO "MESSAGE_PROCESSORS" (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job')
    at org.springframework.jdbc.datasource.init.ResourceD atabasePopulator.executeSqlScript(ResourceDatabase Populator.java:183)
    at org.springframework.jdbc.datasource.init.ResourceD atabasePopulator.populate(ResourceDatabasePopulato r.java:120)
    at org.springframework.jdbc.datasource.init.DataSourc eInitializer.afterPropertiesSet(DataSourceInitiali zer.java:80)
    ... 39 more
    Caused by: org.h2.jdbc.JdbcSQLException: Table "MESSAGE_PROCESSORS" not found; SQL statement:
    INSERT INTO "MESSAGE_PROCESSORS" (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job') [42102-159]
    at org.h2.message.DbException.getJdbcSQLException(DbE xception.java:329)
    at org.h2.message.DbException.get(DbException.java:16 9)
    at org.h2.message.DbException.get(DbException.java:14 6)
    at org.h2.command.Parser.readTableOrView(Parser.java: 4747)
    at org.h2.command.Parser.readTableOrView(Parser.java: 4725)
    at org.h2.command.Parser.parseInsert(Parser.java:949)
    at org.h2.command.Parser.parsePrepared(Parser.java:37 5)
    at org.h2.command.Parser.parse(Parser.java:279)
    at org.h2.command.Parser.parse(Parser.java:251)
    at org.h2.command.Parser.prepareCommand(Parser.java:2 17)
    at org.h2.engine.Session.prepareLocal(Session.java:41 5)
    at org.h2.engine.Session.prepareCommand(Session.java: 364)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConn ection.java:1119)
    at org.h2.jdbc.JdbcStatement.executeUpdateInternal(Jd bcStatement.java:121)
    at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatem ent.java:110)
    at org.apache.commons.dbcp.DelegatingStatement.execut eUpdate(DelegatingStatement.java:228)
    at org.springframework.jdbc.datasource.init.ResourceD atabasePopulator.executeSqlScript(ResourceDatabase Populator.java:169)
    ... 41 more

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    Hello

    1) use code tags
    2) you have declared
    Code:
    INSERT INTO MESSAGE_PROCESSORS (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job');
    But the error saids
    Code:
    Caused by: org.h2.jdbc.JdbcSQLException: Table "MESSAGE_PROCESSORS" not found; SQL statement:
    INSERT INTO "MESSAGE_PROCESSORS" (PROCESS_NAME, PROCESS_DESC) VALUES ('PRI', 'PRI Batch Job') [42102-159]

    Therefore in some insert statement you are using "MESSAGE_PROCESSORS" and not MESSAGE_PROCESSORS
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •