3 Replies Latest reply on Sep 19, 2007 2:23 AM by Mohammad Norouzi

    conversation ends unexpectedly!

    Mohammad Norouzi Novice

      Hello,

      I have a SFSB with an action method as follows:

      @Stateful
      @Name("searchResult")
      @Scope(CONVERSATION)
      public class SearchResultAction implements SearchResult {
       //code ....
      
       public String export() {
       if(!exportAvailable) {
       if(!ActionUtil.clearUserExportFolder(user,FacesContext.getCurrentInstance())) {
       logger.warn("some files may not be deleted!");
       }
       }
       try {
       if(!ExportDataUtil.checkCapacity(indexResultSet)) {
       FacesMessages.instance().add("Sorry! too many records to export, please refine your query to decline the result");
       return "";
       }
      
       logger.debug("exporting....");
       logger.debug("request parameter:" + exportType);
      
       ExportDataUtil export = new ExportDataUtil();
      
       String path = ActionUtil.checkUserExportFolder(user,FacesContext.getCurrentInstance());
      
      //commented code
      
      // if("xml".equals(exportType)) {
       // export.exportToXML(path,indexResultSet,columnHeaders);
       // }else if("pdf".equals(exportType)) {
       // export.exportToPDF(path,indexResultSet,columnHeaders);
       // }else if("word".equals(exportType)) {
       // export.exportToRTF(path,indexResultSet,columnHeaders);
       // }else if("access".equals(exportType)) {
       // export.exportToAccess(path,indexResultSet,columnHeaders);
       // }else if("excel".equals(exportType)) {
       // export.exportToExcel(path,indexResultSet,columnHeaders);
       // }else {
       // logger.error("unable to export, invalid parameter.");
       // FacesMessages.instance().add("Unable to export, an unexpected error has been occured, please try again.");
       // return "";
       // }
      
       exportAvailable = true;
       return "exportList";
       }catch (Exception e) {
       e.printStacktrace();
       exportAvailable = false;
       return "";
       }
       }
      
      }
      


      as you can see, I commented out the part of code in which I export the information to various formats, this is work with no problem but if I remove the comment, at this point the method will create the exported file correctly, but suddenly the conversation will ends!!!

      what is wrong with this code? I checked the ExportDataUtil and put many logs to see if there is any exception but no exception occurred, and the exported file will be created when this method is called

      would you tell me what is the problem.

      any help is appreciated


        • 1. Re: conversation ends unexpectedly!
          Mohammad Norouzi Novice

          in the ExportDataUtil I used FileOutputStream to create related files on the disk. Does this make the problem?

          • 2. Re: conversation ends unexpectedly!
            Mohammad Norouzi Novice


            I put some log in my code, here is the result:

            this is ExportDataUtil.exportToExcel() method:

             public void exportToExcel(String filepath,Map<Class, IndexResultSet> indexResultSet,Map<IndexCategory, ColumnHeaderList<ColumnHeader>> columnHeaders) throws Exception {
             logger.debug("building Excel's sheet is in progress...");
             int rowCount = 0;
             int colCount = 0;
             int savedCurrentIndex = 1;
             int x = 0;
             logger.debug("--->>>> "+x++);
             String filename = ".xls";
            
             // Create Excel Workbook and Sheet
             HSSFWorkbook wb = new HSSFWorkbook();
             logger.debug("--->>>> "+x++);
             HSSFSheet sheet = wb.createSheet(filename);
             HSSFHeader header = sheet.getHeader();
             header.setCenter(filename);
             logger.debug("--->>>> "+x++);
             HSSFFont tahomaFont = wb.createFont();
             tahomaFont.setFontName("Tahoma");
             logger.debug("--->>>> "+x++);
            
            


            and the result is:
            DEBUG building Excel's sheet is in progress...
            DEBUG --->>>> 0
            DEBUG --->>>> 1
            starting IndexSearchAction
             DEBUG destroying IndexSearchAction...
            DEBUG --->>>> 2
            DEBUG --->>>> 3
            DEBUG --->>>> 4
            DEBUG --->>>> 5
            DEBUG --->>>> 6
            DEBUG --->>>> 7
            DEBUG --->>>> 11111
            DEBUG --->>>> 22222
            DEBUG --->>>> 3333
            DEBUG --->>>> 4444
            DEBUG --->>>> 5555
            DEBUG --->>>> 6666
            DEBUG --->>>> 7777
            DEBUG --->>>> 8888
            DEBUG --->>>> 9999
            DEBUG --->>>> aaaa
            DEBUG --->>>> bbbb
            DEBUG --->>>> cccc
            INFO Export to Excel done.
            DEBUG EXCEL-END
            


            as you can see, after two logs is displayed, the conversation ends, this is highlighted in green

            any idea?

            • 3. Re: conversation ends unexpectedly!
              Mohammad Norouzi Novice

              sorry for the highlight color

              DEBUG building Excel's sheet is in progress...
              DEBUG --->>>> 0
              DEBUG --->>>> 1
              
              starting IndexSearchAction
               DEBUG destroying IndexSearchAction...
              
              DEBUG --->>>> 2
              DEBUG --->>>> 3
              DEBUG --->>>> 4
              DEBUG --->>>> 5
              DEBUG --->>>> 6
              DEBUG --->>>> 7
              DEBUG --->>>> 11111
              DEBUG --->>>> 22222
              DEBUG --->>>> 3333
              DEBUG --->>>> 4444
              DEBUG --->>>> 5555
              DEBUG --->>>> 6666
              DEBUG --->>>> 7777
              DEBUG --->>>> 8888
              DEBUG --->>>> 9999
              DEBUG --->>>> aaaa
              DEBUG --->>>> bbbb
              DEBUG --->>>> cccc
              INFO Export to Excel done.
              DEBUG EXCEL-END