Inside an EJB you can have a FileStream representation using the classloader and Threadl.
here goes a little sample:
ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream stream = loader .getResourceAsStream("rolesAllowed.properties");
here rolesAllowed.properties is a file resource located at $JBOSS_HOME/server/default/conf.
you can use any relative path that is present on the ejb classpath.
I hope this helps you.
I am using FileInputStream inside an EJB 3 session bean. It works perfectly. What error message do you get?
Thanks gmuzzillo and JUnkie,
I know that using java.io.File and java.io.InputStream (and subclasses) for file access work, however I get a warning from by IDE (which is IntelliJ IDEA V6.0) which says "usage of java.io.File not allowed in EJB".
Same for FileInputStream.
Again, the code compiles and works well.
Does anyone know about the "correct" rules of how to access files from inside an EJB?
i believe if you want to access resources that exist outside of the app. server's container you should use JCA.