-
1. Re: File storage in Jboss 4.2.3
ybxiang.china Sep 10, 2012 10:26 PM (in response to jonathanfuentes)File storage has nothing to do with JBoss.
(1) After file is uploaded to jboss through uploade component, the file is just a stream, you can save it anywhere, for example /home/xxx/file-repository.
(2) create a web.xml in /home/xxx/file-repository/WEB-INF. then deploy file-repository as an web applicatoin into jboss or jetty or tomcat, or apache.
(3) Then uploaded file(example: a.doc, dirctoryName/b.doc) can be access through URL:
You can synchronize this file-repository to another filer server to back up your files.
-
2. Re: File storage in Jboss 4.2.3
sfcoy Sep 11, 2012 12:29 AM (in response to jonathanfuentes)Hi there,
First of all, I will draw your attention to (the often ignored) section 21.2.2 Programming Restrictions of the EJB spec which says, amongst other things:
{quote}An enterprise bean must not use the java.io package to attempt to access files and directories in the file system.{quote}
But if you are 100% certain that you will never cluster your application or otherwise run it on several nodes at once then you will probably get away with just using normal file i/o and store your files anywhere you want. There is still an important caveat in that what you are doing is not transactional and if you for some reason you have transaction rollbacks, your file i/o will not be reverted in any way.
For this reason you may better off using something like http://sourceforge.net/projects/filera/, which is a JCA 1.5 compatible resource adapter for performing file operations. I don't know much about this product, I just googled it, btw. There are several other examples around that you can look at.
In the past, I've always stored documents as blobs in a database table rather than attempt to use the file system. It's possible to add JPA annotations to blob/clob fields and then use streaming i/o operators to read/write to them in a way that is scalable and transactional.