1

It seems that it is forbidden to read files from an EJB as stated in this link:

http://java.sun.com/blueprints/qanda/ejb_tier/restrictions.html#file_access

Enterprise beans aren't allowed to access files primarily because files are not transactional resources. Allowing EJBs to access files or directories in the filesystem, or to use file descriptors, would compromise component distributability, and would be a security hazard.

What does "compromise component distributability" ???

Mr.Eddart
  • 10,050
  • 13
  • 49
  • 77
  • An interesting discussion on the matter: https://www.coderanch.com/t/161394/java-EJB-SCBCD/certification/Why-access-file-system-EJB – Mr.Eddart Nov 13 '12 at 18:02

1 Answers1

1

Excerpt from How to Be Distributable from Enterprise Servlets and J2EE:

An EJB may be distributed across a number of backend machines and may be moved between machines at the container's discretion. To enable this distribution model, EJB must follow a strict specification-defined ruleset for what they can and cannot do.

File system could be different from machine to machine and file descriptors definitely are. Using them could prevent EJB migration and/or passivation.

See also

Community
  • 1
  • 1
fglez
  • 8,422
  • 4
  • 47
  • 78