2 Replies Latest reply on Sep 11, 2012 12:29 AM by sfcoy

    File storage in Jboss 4.2.3

    jonathanfuentes

      Hi to all, i just wanna ask you if Jboss 4.2.3 supports file storage inside it. This is because i have an application in SEAM 2 to manage construction projects. This applications follows a flow where first you enter a project request and enter some financial information, anyways, there's a step in the flow where the users want to upload documents, for example .doc documents, .pdf or .jpg . So, i don't wanna store the files in the database (PostgreSQL), i wanna store it inside the Jboss server, i'm going to create the folder structure to store the documents of each project request without mixing them, but i don't know what's the best approach to do this. I want to store files and after be capable of download those files from the application, but i don't know how to do that. I don't want that you do my homework, is just that i don't know where to start, so if you can provide me complete information about how to do it, thank you, or if you just wanna give me a guide o tell me about some Jboss topic related to file storage then thank you too. I just wanna know if this is possible and if is possible, which directory is the best inside jboss to store files.

       

      Regards.

        • 1. Re: File storage in Jboss 4.2.3
          ybxiang.china

          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

            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.