This content has been marked as final.
Show 4 replies
-
1. Re: Access a file resource from EJB3.0
gmuzzillo Oct 25, 2007 7:26 AM (in response to skymic)Hi!!
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.
Best
Gustavo -
2. Re: Access a file resource from EJB3.0
junkie Oct 26, 2007 12:47 PM (in response to skymic)I am using FileInputStream inside an EJB 3 session bean. It works perfectly. What error message do you get?
-
3. Re: Access a file resource from EJB3.0
skymic Oct 30, 2007 9:52 AM (in response to skymic)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? -
4. Re: Access a file resource from EJB3.0
waynebaylor Oct 30, 2007 12:09 PM (in response to skymic)i believe if you want to access resources that exist outside of the app. server's container you should use JCA.