6 Replies Latest reply on Apr 25, 2003 8:09 AM by cmiles74

    Image Manipulation, ImageIO, getDefaultToolkit

    cmiles74

      I have a stateless bean that does two things; it writes some data about an image to a table and then it write the image file and two thumbnails to disk. The problem I am having is that whenever I try to make an ImageIO call, the transaction just hangs.

      I tried switching to toolkit calls, but I am seeing the same issue. Is there something trickier that I have to do? Most of all, am I doing something crazy?

      Any help would be greatly appreciated,
      -- Miles

      Here is the chunk of code that is hanging:

      // wrap an input stream around the byte data
      ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream( byteData );

      // read in the image
      logger.info( "Reading in the image data..." );
      BufferedImage bufferedImageOriginal = ImageIO.read( bytearrayinputstream );

      // write the file to disk
      logger.info( "Writing the full size image to " + fileImage.getAbsolutePath() );
      ImageIO.write( bufferedImageOriginal, "jpg", fileImage );

      The log file says:

      2003-04-24 13:08:09,380 INFO [FILE] Image object created
      2003-04-24 13:08:09,381 INFO [FILE] Writing image data to disk
      2003-04-24 13:08:09,383 INFO [FILE] byteData length: 130970
      2003-04-24 13:08:09,383 INFO [FILE] Reading in the image data...
      13:13:09,327 WARN [TxCapsule] Transaction XidImpl [FormatId=257, GlobalId=Greta//42, BranchQual=] timed out. status=STATUS_ACTIVE
      2003-04-24 13:13:09,327 WARN [org.jboss.tm.TxCapsule] Transaction XidImpl [FormatId=257, GlobalId=Greta//42, BranchQual=] timed out. status=STATUS_ACTIVE

      The image size is report the same from the swing client and the server log file, my belief is that the image is getting to the server intact.

        • 1. Re: Image Manipulation, ImageIO, getDefaultToolkit

          I would guess your

          "Reading in the image data..."

          is not completing causing a Tx timeout after the
          standard 5 minutes.

          Regards,
          Adrian

          • 2. Re: Image Manipulation, ImageIO, getDefaultToolkit
            cmiles74

            Yes, it looks like that is the case. My question is, why does it time out while reading the data?

            BufferedImage bufferedImageOriginal = ImageIO.read( bytearrayinputstream );

            This should complete right away, it's reading from a byte array that it already has on hand. I do the same thing on the client before sending the byte array and it completes fine; the data in the array is good.

            Confused,
            -- Miles

            • 3. Re: Image Manipulation, ImageIO, getDefaultToolkit

              I have no idea.

              You will have to ask whoever develops
              ImageIO there is no jboss code here.

              Regards,
              Adrian

              • 4. Re: Image Manipulation, ImageIO, getDefaultToolkit
                cmiles74

                I will certainly endeavor to contact someone who works on the ImageIO code by submitting a bug report to Sun, but I fully expect them to complain that this is a JBoss issue. After all, it works fine in a Swing application.

                I did not post this issue expecting someone to fix it for me, on the contrary I already have a workaround in place (I generate all three images on the client and send the data to the server). While this generates more network traffic, it's better than nothing. My hope was that someone else had seen a similar issue and might have something constructive to offer.

                Sincerely,
                -- Miles

                • 5. Re: Image Manipulation, ImageIO, getDefaultToolkit

                  Do you know about Enterprise Media beans?

                  There is an implementation of this in jboss4.

                  Maybe one of the developers on this project
                  can help you? I doubt they read the EJB forum. :-)

                  Regards,
                  Adrian

                  • 6. Re: Image Manipulation, ImageIO, getDefaultToolkit
                    cmiles74

                    That does sound like what I'm looking for.

                    I'm thinking that calling out to AWT must not be allowed from the server. This makes sense, I guess, as on UNIX platforms you aren't guaranteed to have a windowing environment runnning.

                    Thanks,
                    -- Miles