jQuery in Action, 2nd edition*
The moose likes EJB and other Java EE Technologies and the fly likes Accessing files from EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accessing files from EJB" Watch "Accessing files from EJB" New topic
Author

Accessing files from EJB

John Lindwall
Ranch Hand

Joined: May 29, 2002
Posts: 31
I'd like to have some property files available from an EJB. The EJB spec says not to access files using java.io from an EJB. Um ... OK.
What are some practical solutions to this issue?
I dislike user getResource() because (being classpath-based) it opens the door to configuration errors. "Oh you mean we're loading foo.properties from the classpath? I didn't realize that and added my own foo.properties to the classpath and it was loaded instead of the expected one". I like something more explicit.
Lilac Ezer
Greenhorn

Joined: Apr 08, 2003
Posts: 8
I think the preferred solution is to declare your properties in the EJB deployment descriptors in <env-entry> elements.
I think if you called getResource or used the Preferences API in jdk1.4, that is still 'cheating' because I/O calls may still take place, even if you are not calling a file directly.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Accessing files from EJB