I have a java class that uses the file "keystore\test.keystore" in a web application. This keystore file is used to encrypt and decrypt the credit card on my web site. But when the method to encrypt the credit is
getting called I am getting the following error.
I guess the file has to be on the server and its not finding it where it supposed to be.
Where should I copy this file on to the server? I am currently testing this in my localhost and I use a jboss server.
How did you set the directory? It's probably not pointed to the right place.
From the error text you show, it looks like you said that the directory is "keystore". That might work, depending on what the root is relative from which File() interprets your given directory. Better would be for the directory to be a complete path, starting at the system's root directory.
Joined: Nov 15, 2005
I think the keystore folder should have been in the classes directory. Looks like it's working if it's in the classes directory.
Thank you for helping.
With web applications you should always use the ServletContext.getRealPath method to turn paths relative to the web application root to absolute paths.
I wouldn't put the keystore folder in your classes folder; make it a direct sub folder of the WEB-INF folder. That would make the parameter to getRealPath "WEB-INF/keystore/test.keystore". Because it's in WEB-INF it cannot be found by trying to access it directly; only your web application itself has access to it.