Announcement Announcement Module
Collapse
No announcement yet.
Running batch samples in Oracle 10g Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running batch samples in Oracle 10g

    Hi,

    I'm trying to run the sample jobs obtained from source at http://springframework.svn.sourcefor...g-batch/trunk/. Initially I downloaded the framework along with samples; Using maven and jdk 1.5 I was able to compile, run the associated tests with HSQLDB(default). I was still getting exceptions trying to update the in-memory database. Since I need to implement my application using Oracle 10g, I thought of using oracle to see how the samples work. I modified the following to point to oracle database.

    \samples\src\main\resources\batch.properties .
    \execution\src\main\resources\batch.template.prope rties
    \samples\src\main\resources\data-source-context-init.xml
    corrected the dialect in \samples\src\main\resources\hibernate-context.xml to point to oracle
    \execution\src\main\resources\schema-oracle10g.sql

    I am getting the exception listed below.
    HTML Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobLauncher' defined in class path resource [simple-container-definition.xml]: Cannot resolve reference to bean 'simpleJobRepository' while setting bean property 'jobRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleJobRepository' defined in class path resource [simple-container-definition.xml]: Cannot resolve reference to bean 'sqlJobDao' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlJobDao' defined in class path resource [simple-container-definition.xml]: Cannot resolve reference to bean 'jobIncrementer' while setting bean property 'jobIncrementer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobIncrementer' defined in class path resource [data-source-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'columnName' of bean class [org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer]: No property 'columnName' found
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:274)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1274)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1042)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:296)
    	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:950)
    	at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:711)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
    	at org.springframework.batch.sample.AbstractBatchLauncherTests.createApplicationContext(AbstractBatchLauncherTests.java:53)
    	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:132)
    	at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
    	at junit.framework.TestResult$1.protect(TestResult.java:110)
    	at junit.framework.TestResult.runProtected(TestResult.java:128)
    	at junit.framework.TestResult.run(TestResult.java:113)
    	at junit.framework.TestCase.run(TestCase.java:124)
    	at junit.framework.TestSuite.runTest(TestSuite.java:232)
    	at junit.framework.TestSuite.run(TestSuite.java:227)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleJobRepository' defined in class path resource [simple-container-definition.xml]: Cannot resolve reference to bean 'sqlJobDao' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlJobDao' defined in class path resource [simple-container-definition.xml]: Cannot resolve reference to bean 'jobIncrementer' while setting bean property 'jobIncrementer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobIncrementer' defined in class path resource [data-source-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'columnName' of bean class [org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer]: No property 'columnName' found
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:274)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
    	at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:447)
    	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:957)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:869)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:514)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:268)
    	... 33 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlJobDao' defined in class path resource [simple-container-definition.xml]: Cannot resolve reference to bean 'jobIncrementer' while setting bean property 'jobIncrementer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobIncrementer' defined in class path resource [data-source-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'columnName' of bean class 
    	... 47 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobIncrementer' defined in class path resource [data-source-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'columnName' of bean class 
    	... 59 more
    Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'columnName' of bean class 
    	... 67 more
    Has anyone tried testing the samples in Oracle? Can you guide me on where the problem lies, or I have missed anything in the process? Couldn't find much help in the forum and the web, and hence this post.

    Thanks,
    -Mahesh

  • #2
    I'm guessing you set the batch.database.incrementer.class to something that doesn't work with Oracle. What are you using? One of the out-of-the-box incrementers might work (despite the fact that none is targeted at Oracle). You might have to write your own incrementer, or modify the data-source-context.xml (and the DDL) so that it uses an OracleSequenceMaxValueIncrementer. If you get it to work with OracleSequenceMaxValueIncrementer we would be interested in a patch (via JIRA http://opensource.atlassian.com/proj...owse/BATCH-240). I'm sure someone else must be using Oracle, but most of the folks I know using Spring Batch in anger seem to be on DB2 for some reason.

    I would also be interested to know what errors you were seeing with HSQLDB, as that is what we use in our CI build, so it definitely works for most people.

    Comment


    • #3
      You should be able to just comment out the column name line in batch.properties, it's only there to support HSQLDB.

      Comment


      • #4
        UncategorizedSQLException

        I successfully run simpleTaskletJob in Oracle as well as in HSQL DB. But i got problem running tradeJob in Oracle, while it ran successfully in HSQL DB.
        I ran the above mentioned jobs through JUnit test cases and also through Job Launcher.

        Here is the exception i got when i tried to run tradeJob in oracle:

        Code:
        org.springframework.jdbc.UncategorizedSQLException: Executing query; uncategorized SQLException for SQL [SELECT id, quantity, price, customer from TRADE]; SQL state [null]; error code [17023]; Unsupported feature; nested exception is java.sql.SQLException: Unsupported feature
        Caused by: java.sql.SQLException: Unsupported feature
        	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
        	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
        	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
        	at oracle.jdbc.dbaccess.DBError.throwUnsupportedFeatureSqlException(DBError.java:690)
        	at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:3292)
        	at org.springframework.batch.io.cursor.JdbcCursorInputSource.executeQuery(JdbcCursorInputSource.java:324)
        	at org.springframework.batch.io.cursor.JdbcCursorInputSource.open(JdbcCursorInputSource.java:564)
        	at org.springframework.batch.io.cursor.JdbcCursorInputSource.read(JdbcCursorInputSource.java:203)
        	at org.springframework.batch.io.cursor.JdbcCursorInputSource$$FastClassByCGLIB$$762918c9.invoke(<generated>)
        	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
        	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:695)
        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
        	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
        	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
        	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630)
        	at org.springframework.batch.io.cursor.JdbcCursorInputSource$$EnhancerByCGLIB$$7cd4e57c.read(<generated>)
        	at org.springframework.batch.item.provider.InputSourceItemProvider.next(InputSourceItemProvider.java:48)
        	at org.springframework.batch.execution.tasklet.ItemProviderProcessTasklet.execute(ItemProviderProcessTasklet.java:141)
        	at org.springframework.batch.execution.step.simple.SimpleStepExecutor.doTaskletProcessing(SimpleStepExecutor.java:372)

        Comment


        • #5
          Are you also using Oracle 10g? The code that is throwing the error is trying to open a read_only cursor. Is the supported in your database?

          Comment


          • #6
            re:

            i am using oracle 9i.

            Comment


            • #7
              Oracle10g not working

              I have done the changes as mentioned in the above post. I still get the following error:

              java.lang.ClassCastException: java.lang.Long

              Comment


              • #8
                What JVM version are you using? We target 1.4 (and above) with our distributed jars. If you compiled it yourself you can figure out how to make it compatible.

                Comment


                • #9
                  Re:

                  Hi Dave,
                  I am using JDK1.5. The oracle jar, I used was not correct. Now its working fine.

                  Comment


                  • #10
                    RestartFunctionalTest Error

                    The RestartFunctionalTest when executed alongwith oracle as database, it inserts 7 rows i.e. it restart from the first data. Because of this, the unit test fails.

                    Code:
                    junit.framework.AssertionFailedError: expected:<5> but was:<7>
                    	at junit.framework.Assert.fail(Assert.java:47)
                    	at junit.framework.Assert.failNotEquals(Assert.java:280)
                    	at junit.framework.Assert.assertEquals(Assert.java:64)
                    	at junit.framework.Assert.assertEquals(Assert.java:198)
                    	at junit.framework.Assert.assertEquals(Assert.java:204)
                    	at org.springframework.batch.sample.RestartFunctionalTests.testRestart(RestartFunctionalTests.java:85)
                    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                    	at java.lang.reflect.Method.invoke(Unknown Source)
                    	at junit.framework.TestCase.runTest(TestCase.java:164)
                    	at junit.framework.TestCase.runBare(TestCase.java:130)
                    	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:120)
                    	at junit.framework.TestSuite.runTest(TestSuite.java:230)
                    	at junit.framework.TestSuite.run(TestSuite.java:225)
                    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
                    	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)
                    It works absolutely fine with hsqldb.

                    Comment


                    • #11
                      It works for me. What version of Spring Batch are you using?

                      Comment


                      • #12
                        Re

                        I am using the samples provided with spring-batch-1.0.0.m3-with-dependencies

                        Comment


                        • #13
                          Even I got similar Assertion Failuer message in RestartFunctionTest. I used spring-batch-1.0.0.m3-with-dependencies release version and back end is Oracle.The sample code is inserting 2 records in the database the throws execption(as desired) and the sample code restarts all over gain and the insert 5 records including previous 2 that makes it 7(whereas expected value is 5 i.e. starting from 3rd record till 5th record).
                          Any suggestion why it is behave in this manner.
                          I would be glad if I can get location in the sample code where the batch framework campare the no. of records inserted(commited) and restart from next record.

                          Comment


                          • #14
                            It seems there is a problem with the way the restart data is being persisted. Can someone confirm that (like me) it actually works with 10g in some cases (I just downloaded the XE edition and it worked out of the box)? Can someone with a test failure also get us some more information about the restart data in between runs (it is stored in the batch_step table in plain text form)? Could there be some unusual set up where varchar columns have limited sizes smaller than required? I'm struggling to think of why it would work for me and not someone else.

                            Comment


                            • #15
                              Hello,
                              In reference with the above problem, I would like to provide the following input :

                              Oracle JARs used : classes12.jar and ojdbc14.jar

                              According to me, the problem is due to the cursor not maintaining the value of the last fetch record rather I would say JARs used might be incompatible to work with cursor properly(assumption) or there has to be some configuration done in my Oracle10g database.

                              Comment

                              Working...
                              X