| Author |
How to access file in EJB
|
Sandeep Ghosh
Ranch Hand
Joined: Jan 23, 2002
Posts: 145
|
|
Hi Friends, I am storing in <env-entry> pathname where crt and pvt files are located.I am writing this in ejb-jar.xml. <env-entry> <env-entry-name>myCertFile</env-entry-name> <env-entry-value>http://localhost:8080/WebFolder/abc.crt</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> my abc.crt is in root directory of the web. When my accessing it is throwing fileNotFoundException. Plz tell me where I am going wrong . Thanks in adv. Sonu
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
|
You can put the file in ejb-jar file and access the fie.
|
Groovy
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
How are trying to accessing the file?
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
|
Are you using URL ?
|
 |
Sandeep Ghosh
Ranch Hand
Joined: Jan 23, 2002
Posts: 145
|
|
I am trying to access using InputStream class. Thanks Sonu
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
Ok, now could you post the piece of your code where you get that InputStream from? Are you saying new FileInputStream("foobar.txt"), getResourceAsStream("foobar.txt") or what?
|
 |
Sandeep Ghosh
Ranch Hand
Joined: Jan 23, 2002
Posts: 145
|
|
I am using a third party api where I have to mention path of the file and they are using FileInputStream(). It is throwing FileNotFound exception when I passing the URL but when I am passing the complete path name C:\.... it is working. Sonu
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
Ok. Then you need to either read the manual (if there is one) and experiment. Take a guess at where the current directory is (although I think you can read this as a system property somehow) and construct a relative path accordingly; and repeating until you don't get the exception.
|
 |
 |
|
|
subject: How to access file in EJB
|
|
|