6 Replies Latest reply on Nov 5, 2010 10:25 AM by gred

    Donwloading file

    gred
      Hi all.

      I'm facing the following problem.

      I'm using seam 2.2 with richfaces 3.3.1. I'm using the following lines of code to download a file through seam:
      ttpServletResponse response = (HttpServletResponse)extCtx.getResponse();
                      response.setContentType("images/jpeg");
              response.addHeader("Content-disposition", "attachment; filename=\"" + newCustomer.getFile().getFileName() +"\"");
              FileInputStream fis = null;
                      try {
                              byte[] fData = new byte[4096];
                              fis = new FileInputStream(new File(newCustomer.getFile().getFilePath() + newCustomer.getFile().getFileName()));
                              ServletOutputStream os = response.getOutputStream();
                              while(fis.read(fData, 0, 4096) != -1) {
                                      os.write(fData, 0, 4096);
                              }
                             
                              //os.write(fData);
                              os.flush();
                              os.close();
                              FacesContext.getCurrentInstance().responseComplete();
                              //facesContext.responseComplete();
                      } catch(Exception e) {
                              log.error("\nFailure : " + e.toString() + "\n");
                      }

      When I deploy my application to an enterprise application platform (v 5.0) everything works fine. When I deploy the EXACT same ear to a jboss application server 5.0.0 I get the following error:
      Failure : java.util.MissingResourceException: Can't find resource for bundle org.ajax4jsf.Messages$EmptyResourceBundle, key CREATE_STREAM_INFO

      in line:
      ServletOutputStream os = response.getOutputStream();

      I can't find anything in the web for this issue.

      I though that the problem is that the richfaces resource bundle lies in a lib inside the war of the application where the resource CREATE_STREAM_INFO can see it.

      So I thought of moving all the richfaces lib to the ear but I don't know if I'm on the right track for this issue!!

      Thank you!
        • 1. Re: Donwloading file
          cash1981

          I have same problem.
          Did you solve it?

          • 2. Re: Donwloading file
            gred

            In case you are still interesting.... - or whoever...
            Move all of the seam - and richfaces jars - in the ear's lib folder except the jboss-seam.jar and the mvel.jar which should be placed in the root of the ear.

            In the war's lib folder I only kept the jboss-seam-ui.jar, jboss-seam-mail.jar.
            And that's it!

            I'm pretty sure it has something to do with a very specific jar - or a couple of jars - that should be put in a place where the ejb jar has access but I'm not sure which is it. With this approach everything works.

            • 3. Re: Donwloading file
              cash1981

              If I am not mistaken, I think I solved it by moving the code away from my EJB to a normal JavaBean.
              That made all the difference.

              • 4. Re: Donwloading file
                gred

                Inderesting approach! The java bean you used you place it in the ejb jar or the war???

                • 5. Re: Donwloading file
                  cash1981

                  George Kokkinos wrote on Nov 05, 2010 05:07:


                  Inderesting approach! The java bean you used you place it in the ejb jar or the war???


                  I am using a EAR, but it is equivalent as putting it in the war.

                  • 6. Re: Donwloading file
                    gred

                    Nice. Thanks for sharing this tip with me!