File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How to access file in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to access file in EJB" Watch "How to access file in EJB" New topic
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: 8898

You can put the file in ejb-jar file and access the fie.


Groovy
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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: 8898

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
    
    5
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
    
    5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access file in EJB
 
Similar Threads
BMP Deployment descriptors
getInitParameter with a MessageDrivenBean
Problem looking up local interface of Session Beans - WSAD 5.1, WAS 5.0 Test Env
env-entry tag
where should I put ejb-jar.xml