I keep getting this error when i try to read the content of a text file in my helper class for an entity bean.
Can someone help me to solve this please. Thank You
-
access denied (java.io.FilePermission...) (1 messages)
- Posted by: who know
- Posted on: October 20 2003 06:26 EDT
Threaded Messages (1)
- access denied (java.io.FilePermission...) by Gal Binyamini on October 21 2003 04:36 EDT
-
access denied (java.io.FilePermission...)[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: October 21 2003 04:36 EDT
- in response to who know
Entity beans are not supposed to access the file system directly, even for reads, because if you had an entity bean deployed in more than one machine in a cluster the behavior would depend on which computer it is installed in. This is something that the EJB spec tries to avoid.
To solve your problem, you can place the file in some central HTTP server or something similar and grab it in your entity bean from there, or you can include the file in the EJB jar file and then grab it using MyEJB.class.getResourceAsStream(myFile). Both of these options make it so that when you update your EJB deployment, all cluster nodes get the updated text file. In the long run, although it's a little more tedious than just openning a file in some predefined location, this strategy could save you time and headaches in maintenance.