You cannot access the file system from an ejb.
But you could write an mbean which does the i/o stuff and call it from the ejb.
See the Documentation for how to write an mbean.
Yes, you can use the java.io package! Just not for
file or directory access to a local filesystem.
The points are made in (EJB 1.1) 18.1.2 are
very clear about this. Files in and of themselves are
not well suited to a distributed, transactional
The next point that EJBs can be socket clients. This
means they must be able to import java.net.* AND
java.io.*. This works for me in JBoss 3.0.0. After all,
how can we call out to Web Services (hint, hint) from
EJBs which the draft J2EE 1.4 (EJB 2.1) says that we
can and should.
Bottom line, using java.io.* for file I/O is a definite
no-no as per the spec.
Since you mention WebSphere, I can say that WAS 4.0.1
happily writes to the local filesystem which it should
not, without a whinge. Go figure. So much for