• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

FileNotFoundException please help.

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

[STDOUT] java.io.FileNotFoundException: keystore\test.keystore (The system cannot find the path specified)

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.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most likely, the error is due to a statement of the form

java.io.File f = new File(directory,filename);

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.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 22445
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that is a good idea.
Thanks.
 
Rob Spoor
Marshal
Posts: 22445
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic