java - Why is my PathResource not readable? -


i try write spring batch application reads csv-file , stores contents in database. not able create flatfileitemreader because illegalstateexception stating input resource must readable (reader in 'strict' mode).

this configuration reader:

@bean public itemreader<cadsystem> cadsystemreader(final path backupdirectory,         final cadsystemfieldsetmapper fieldsetmapper) {     final flatfileitemreader<cadsystem> reader = new flatfileitemreader<>();     final defaultlinemapper<cadsystem> linemapper = new defaultlinemapper<>();     final pathresource resource = new pathresource(backupdirectory.resolve("cad_systems.csv"));      linemapper.setlinetokenizer(new delimitedlinetokenizer(";"));     linemapper.setfieldsetmapper(fieldsetmapper);     reader.setresource(resource);     reader.setlinemapper(linemapper);      return reader; } 

and stacktrace:

org.springframework.batch.item.itemstreamexception: failed initialize reader     @ org.springframework.batch.item.support.abstractitemcountingitemstreamitemreader.open(abstractitemcountingitemstreamitemreader.java:147)     @ org.springframework.batch.item.support.compositeitemstream.open(compositeitemstream.java:96)     @ org.springframework.batch.core.step.tasklet.taskletstep.open(taskletstep.java:310)     @ org.springframework.batch.core.step.abstractstep.execute(abstractstep.java:195)     @ org.springframework.batch.core.job.simplestephandler.handlestep(simplestephandler.java:148)     @ org.springframework.batch.core.job.abstractjob.handlestep(abstractjob.java:386)     @ org.springframework.batch.core.job.simplejob.doexecute(simplejob.java:135)     @ org.springframework.batch.core.job.abstractjob.execute(abstractjob.java:304)     @ org.springframework.batch.core.launch.support.simplejoblauncher$1.run(simplejoblauncher.java:135)     @ org.springframework.core.task.synctaskexecutor.execute(synctaskexecutor.java:50)     @ org.springframework.batch.core.launch.support.simplejoblauncher.run(simplejoblauncher.java:128)     @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.execute(joblaunchercommandlinerunner.java:210)     @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.executelocaljobs(joblaunchercommandlinerunner.java:227)     @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.launchjobfromproperties(joblaunchercommandlinerunner.java:121)     @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.run(joblaunchercommandlinerunner.java:115)     @ org.springframework.boot.springapplication.runcommandlinerunners(springapplication.java:672)     @ org.springframework.boot.springapplication.afterrefresh(springapplication.java:690)     @ org.springframework.boot.springapplication.run(springapplication.java:321)     @ org.springframework.boot.springapplication.run(springapplication.java:957)     @ org.springframework.boot.springapplication.run(springapplication.java:946)     @ app.main(app.java:11) caused by: java.lang.illegalstateexception: input resource must readable (reader in 'strict' mode): path [d:\backup\cad_systems.csv]     @ org.springframework.batch.item.file.flatfileitemreader.doopen(flatfileitemreader.java:259)     @ org.springframework.batch.item.support.abstractitemcountingitemstreamitemreader.open(abstractitemcountingitemstreamitemreader.java:144)     ... 20 common frames omitted 

the file exists @ d:\backup\cad_systems.csv , readable users/groups.

what causes error?

update

i tried use filesystemresource this

final filesystemresource resource = new filesystemresource(backupdirectory.resolve("cad_systems.csv").tofile()); 

and works. wrong pathresource?

the error caused bug in jdk 7. issue not occur when using java 8.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -