-1

I was following the following basic spring batch tutorial https://spring.io/guides/gs/batch-processing/ .

  • I am using IntelliJ 14 and created a Spring-Batch project

  • I am using Mavin. And I have pom.xml file.

  • I haven't created any file except under src/main/resources/sample-data.csv.
  • I didn't create any DB or JDBCTemplate since I assume it is not needed since the tutorial uses in Memory DB.
  • Mvn clean install works fine even though the Application.java shows me "Couldn't autowire. No beans of jdbcTempalte type can be found" @Autowired JdbcTemplate jdbcTemplate;

  • Spring-config has the following

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd">

  • I am getting an error when I try to do mvn spring-boot:run

    The cause by shows Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: PEOPLE

    What am I missing? I appreciate your help.

Zoe
  • 27,060
  • 21
  • 118
  • 148
WowBow
  • 7,137
  • 17
  • 65
  • 103
  • You sure your DB user has the permission to query? You sure that the table exists? – Makoto Mar 19 '15 at 21:31
  • @Makoto I haven't created any DB. The tutorial mentions "this example uses a memory-based database (provided by @EnableBatchProcessing), meaning that when it’s done, the data is gone." – WowBow Mar 19 '15 at 21:35
  • But [**are you sure the table exists?**](http://stackoverflow.com/questions/24233037/org-hsqldb-hsqlexception-user-lacks-privilege-or-object-not-found-databasechan) – Makoto Mar 19 '15 at 21:35
  • Where does it exist? you mean when it is created on the fly or in the csv file? I am a bit confused. And the log file didn't mention anything about that. Where do I check wether the table existed or not? – WowBow Mar 19 '15 at 21:38
  • This is what I have in the csv file (each full name on a different line ) Jill, Doe Joe ,Doe Justin, Doe Jane, Doe John,Doe – WowBow Mar 19 '15 at 21:42

2 Answers2

2

You should put schema initialisation in your src/main/resources. Spring batch automatically runs schema-@@platform@@.sql during startup and -all tells it to be for all platforms as noted in readme.adoc on github:

Next, you write a SQL script to create a table to store the data.

src/main/resources/schema-all.sql

link:initial/src/main/resources/schema-all.sql

Note: Spring Boot runs schema-@@platform@@.sql automatically during startup. -all is the default for all platforms.

Community
  • 1
  • 1
Nenad Bozic
  • 3,724
  • 19
  • 45
  • Thank you @Nenad. I'll give it a shot. They haven't mentioned anything on the tutorial and I assumed Spring does some of the magic behind :( – WowBow Mar 19 '15 at 22:07
  • Yeah I was curious looking at tutorial how you get schema build so I went to github and realise they explain only there in readme, not on spring tutorial page. Spring boot does lot of magic but it cannot create schema for you :-) – Nenad Bozic Mar 19 '15 at 22:09
  • True that. I was also digging the log file to see where the schema was created and didn't know about the github code they have. I hope this will work out. Let me play with it and I'll choose this as an answer if it works out so that you can get some points .. haha.. Thanks bro. – WowBow Mar 19 '15 at 22:21
  • Now build went fine and the process was started. But I still don't see the output from run() method in Application class. This is the out put http://paste.ofcode.org/BQQzt5wGkV9ykMXTcGzmfD – WowBow Mar 19 '15 at 22:40
  • 1
    Now that is probably whole another problem, try adding some more logging to writer, also to `Application` class but at least we solved db problem. – Nenad Bozic Mar 19 '15 at 22:56
  • Still there is a problem. Because it's printing out the statement in the PersonItemProcessor which doesn't involve any DB connection. However, not the read write processor in Batch Configuration – WowBow Mar 19 '15 at 23:05
  • You can do couple of things so we know what is happening: 1. Add `System.out` in `Àpplication` and `Writter` so we know what is happening and attach log (just add entering writer, entering aplication), place your code somewhere so I can see it since now I can only trust it is same as spring doc and check logged statements on hsql http://stackoverflow.com/questions/9192815/logging-sql-expressions-from-within-hsqldb – Nenad Bozic Mar 20 '15 at 06:01
  • You can get the schema-all file for this tutorial from here: https://github.com/spring-guides/gs-batch-processing/find/master (I faced same problem) – Bajal Dec 17 '15 at 20:02
0

If you want to run a Spring Batch without database configuration then you can use

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

More details can be found on thread Spring-Batch without persisting metadata to database?

Rakesh
  • 4,004
  • 2
  • 19
  • 31