1 Reply Latest reply on Apr 25, 2008 12:08 PM by Bogdan Minciu

    rich:fileUpload listener is leaving Seam conversation

    Bogdan Minciu Newbie

      Hello guys and girls,

      I'm using RichFaces 3.2.1-SNAPSHOT, Seam 2.0.1-GA and Facelets.

      I try to use the rich:fileUpload component to upload 5 pictures at once. This is from my editImageSet.xhtml page:

      <rich:fileUpload fileUploadListener="#{imageSetView.imageUploadListener}"
       acceptedTypes="jpg, jpeg, gif, png">
       <a:support event="onuploadcomplete" reRender="currentImageSetA, messagesA" />

      The editImageSet.xhtml page is called like this: <s:link action="#{imageSetView.editImageSet(imageSet)}" view="editImageSet.xhtml" value="edit"/>, so it starts a new CONVERSATION when entering the page.

      And this is my listener:

      public class ImageSetViewBean implements LocalImageSetView {
       private EntityManager entityManager;
       private ImageSet currentImageSet;
       @Begin(join = true)
       public void editImageSet(ImageSet selectedImageSet) {
       setCurrentImageSet(imageSetDAO.findImageSetById( selectedImageSet.getId() ));
       log.info("images= #0", getImages());
       // also tried without the @Begin
       // also tried with @Begin(join = true)
       @Begin(nested = true)
       public void imageUploadListener(org.richfaces.event.UploadEvent event) throws IOException {
       if (event == null) {
       log.warn("imageUploadListener(): null upload event");
       org.richfaces.model.UploadItem item = event.getUploadItem();
       if(item.isFile()) {
       java.io.File tempFile = item.getFile();
       fileName = tempFile.getAbsolutePath();
      // ---
      // --- some image copying, resizing that was removed from this forum post ---
      // ---
       try {
       Image db_main = new Image();
       log.info("em= #0, db_main= #1", entityManager, db_main);
       } catch(Throwable t) {
       log.info("Image uploaded.");

      Well, the problem is when it comes to the entityManager.persist(db_main) line. It jumps out to the /home.xhtml page saying that The conversation ended, timed out or was processing another request. If I comment the lines that deal with the database (persist, merge) everything works well, all 5 files are uploaded, resized, moved.

      The interesting thing is that the first file (image) uploaded is saved on disk, and even persisted. And it is even added to the currentImageSet. So the method works well just for the first file.

      I investigated this using the Seam Debug Page, and I have seen that the conversation was still active, but somehow, the imageUploadListener() jumped out of it, even if it is annotated with @Begin(join=true).

      Could anyone please tell me why is the imageUploadListener() method jumping out of the conversation if it calls the entityManager?

      Thank you in advance for any hint,


        • 1. Re: rich:fileUpload listener is leaving Seam conversation
          Bogdan Minciu Newbie

          I solved this problem by modifying the concurrent-request-timeout value from:

          <core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid"/>

          <core:manager concurrent-request-timeout="5000" conversation-timeout="180000" conversation-id-parameter="cid"/>

          in components.xml

          Thanks to Zahid: http://www.seamframework.org/Community/RichfileUploadListenerIsJumpingOutOfTheConversation