Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access file in EJB

 
Sandeep Ghosh
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put the file in ejb-jar file and access the fie.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are trying to accessing the file?
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using URL ?
 
Sandeep Ghosh
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to access using InputStream class.
Thanks
Sonu
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic