java.lang.IllegalArgumentException: /home/vcap/app/file.jks (No such file or directory)

1k Views Asked by At

I am trying to deploy Springboot java application into PCF, We have 2-3 files which our application needs at run time like cert file. I have those files under resources folder but getting error file not found exception.

Can anyone suggest me where can i keep the files so that it gets dump into /var/home/app dir in PCF or do i need to create some env so that app will know where to read the files.

1

There are 1 best solutions below

1
Matheus Freire On

Maybe you can put those files on

src/main/java/webapp/folder/file.extension

Then, in your code something like this:

import javax.servlet.ServletContext;

@Autowired
ServletContext servletContext;

static final String SEPARATOR = File.separator;
static final String REALPATH = SEPARATOR + "folder" + SEPARATOR + "file.extension";

String path = servletContext.getRealPath(REALPATH);

So, you can pass the path wherever you want to.