Announcement Announcement Module
Collapse
No announcement yet.
Running samples on PostgreSQL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running samples on PostgreSQL

    The issue was resolved, I was using the wrong database >.<


    Hi,

    I have the m5 distribution, PostgreSQL 8.3.0 using the PostgreSQL 8.3-603 JDBC Driver.

    I'm having the following error while trying to run the FootballJobFunctionalTests:

    Code:
    oorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer' defined in class path resource [data-source-context.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [CREATE TABLE BATCH_JOB_INSTANCE  (
    	JOB_INSTANCE_ID BIGINT  PRIMARY KEY ,  
    	VERSION BIGINT,  
    	JOB_NAME VARCHAR(100) NOT NULL , 
    	JOB_KEY VARCHAR(2500)
    )]; SQL state [25P02]; error code [0]; ERROR: current transaction is aborted, commands ignored until end of transaction block; nested exception is org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:424)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    	at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:243)
    	at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:212)
    	at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:187)
    	at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:140)
    	at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:100)
    	at junit.framework.TestCase.runBare(TestCase.java:125)
    	at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [CREATE TABLE BATCH_JOB_INSTANCE  (
    	JOB_INSTANCE_ID BIGINT  PRIMARY KEY ,  
    	VERSION BIGINT,  
    	JOB_NAME VARCHAR(100) NOT NULL , 
    	JOB_KEY VARCHAR(2500)
    )]; SQL state [25P02]; error code [0]; ERROR: current transaction is aborted, commands ignored until end of transaction block; nested exception is org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
    	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:124)
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:404)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:426)
    	at test.jdbc.datasource.InitializingDataSourceFactoryBean$1.doInTransaction(InitializingDataSourceFactoryBean.java:121)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
    	at test.jdbc.datasource.InitializingDataSourceFactoryBean.doExecuteScript(InitializingDataSourceFactoryBean.java:105)
    	at test.jdbc.datasource.InitializingDataSourceFactoryBean.createInstance(InitializingDataSourceFactoryBean.java:93)
    	at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:120)
    	at test.jdbc.datasource.InitializingDataSourceFactoryBean.afterPropertiesSet(InitializingDataSourceFactoryBean.java:78)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1333)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1299)
    	... 31 more
    Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
    	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:336)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:328)
    	at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:261)
    	at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:419)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:393)
    	... 40 more
    Here is my batch.properties:

    Code:
    batch.jdbc.driver=org.postgresql.Driver
    batch.jdbc.url=jdbc:postgresql://localhost:5432/pbl
    batch.jdbc.user=myuser
    batch.jdbc.password=mypassword
    batch.schema=
    batch.jndi.name=
    batch.naming.factory.initial=
    batch.naming.provider.url=
    #batch.database.vendor=HSQLDB
    batch.schema.script=schema-postgresql.sql
    batch.business.schema.script=business-schema-postgresql.sql
    batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
    batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
    #incrementerParent.columnName=ID
    I added the below line to data-source-context.xml for the sessionFactory bean:

    Code:
    hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
    Is there anything wrong with my configuration? Could anybody please help me as to why this is happening. The example works correctly when using the Hypersonic DB, but not when I try using the PostgreSQL database. I'm new to Spring in general and just trying to figure out Spring Batch, so any advice would be greatly appreciated.

    Cheers,

    James
    Last edited by jamiebarrow; Mar 10th, 2008, 02:44 AM.

  • #2
    Oh also, I changed the databaseType to postgres for the jobRepository bean in simple-container-definition.xml

    Comment


    • #3
      Running samples on PostgreSQL

      I had the same problems. The solution is to first run the sql scripts on the database.

      The scripts are

      schema-postgresql.sql (contained in one of the jars)
      business-schema-postgresql.sql (this one is generated when running mvn test)

      After having done this, the problems vanished, and I was able to run the samples.

      KR
      Patrick Vanbrabant

      Comment


      • #4
        You may also want to think about upgrading to an official release as well.

        Comment


        • #5
          Running samples on PostgreSQL

          The version of Spring Batch I'm currently running I donwloaded last week from SpringSource. It is version 1.1.2.RELEASE.

          I think this should be an official release. If this is not, where can I get an official release.

          KR

          Patrick Vanbrabant

          Comment

          Working...
          X