10 Replies Latest reply on Nov 5, 2002 5:40 AM by Subrahmanyam

    HeuristicRollbackException when a BLOB > 4000 bytes

    Rich Bolen Newbie

      I'm trying to serialize an object and store it as a Blob in an Oracle database (JBoss 2.4.1).

      It works fine until the blob object gets too large (approx. 4000 bytes) and then I get the exception.

      I've tried both the Oracle driver and the Seropto driver. Both behave the same.

      Any ideas?

      Thanks,
      Rich

        • 1. Re: HeuristicRollbackException when a BLOB > 4000 bytes
          Andrew McCulloch Newbie

          I am having the exact same exception. I have tried the Seropto and Oracle drivers as well. My class is a simple wrapper around a byte[].

          class ByteArrayWrapper implements Serializable {
          public byte[] bytes = null;
          }

          I am using a CMP 1.1 (JBoss 2.4.4) Entity bean with a member of type ByteArrayWrapper. During creation of the entity bean I get the following "ERROR,EmbeddedCatalinaServiceSX] StandardWrapperValve[servlet_name]: Servlet.service() for servlet servlet_name threw exception
          javax.transaction.HeuristicRollbackException
          <<no stack trace available>>
          "

          If the data is <~ 4000 bytes the insert works.

          • 2. Re: HeuristicRollbackException when a BLOB > 4000 bytes
            Will Ekiel Newbie

            You're using setBytes(). You should be using setBinaryStream(). Have you looked at the drivers' documentation?

            BTW, how do you like the i-net driver? Is it really faster than Oracle's (I assume you're using the thin one).

            • 3. Re: HeuristicRollbackException when a BLOB > 4000 bytes
              Andrew McCulloch Newbie

              Actually this is CMP1.1 JBoss2.4.4 I am not able to control setBytes() versus setBinaryStream(), am I?

              Yes I like the seropto deiver 100% better than Oracle thin. Its faster and handles LOBs in a standard way (no need to cast to an Oracle specific object to insert data). Also their service is fast, post a problem to their support news group and get a patch in a day or so.

              • 4. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                Andrew McCulloch Newbie

                With help from NetBeans I was able to step through the JAWS code during execution and it is ,in fact, calling setBinaryStream() (my object is of Type Type.JAVA_OBJECT and org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand line 322 in JBoss 2.4.4 calls setBinaryStream when this type is > 2000 bytes) on a serialized version of my object. After calling setParameter on the PreparedStatement for each of my paramerts it attempts to execute the insert and gets an SQLException "com.inet.ora.SQLException: Connection reset by peer: socket write error" It looks to me like the connection was closed before the execute but I can not yet confirm that. The SQLException is rethrown and the HeurisitcRollbackException is the result.

                • 5. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                  Andrew McCulloch Newbie

                  After a LOT of debugging I have narrowed the problem down. When the data being stored in &lt;= 5748 bytes the create method works. When the data is &gt;= 5749 the create fails with the Connection closed by Peer error which causes the HeuristicRollbackException. In both cases the method setBinaryStream is being called.

                  Any clues as to why this may be?

                  • 6. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                    Will Ekiel Newbie

                    Well, I'm sorry, but I have not much else to suggest. I had encountered the 4000 byte limit with setBytes and the Oracle 8.1.7 thin driver and I thought that that was what was going on. It would appear that your problem and Rich's are not the same. I don't have any experience with the i-net driver.

                    • 7. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                      Andrew McCulloch Newbie

                      It turns out that with oracle blobs greater than a certain size (apparently 5748 bytes in my case) on the setBlob method is the only method supported. The oracle driver documentation recommends using setBlob() whenever using blobs, and the following is from the folks at inet in response to my post,
                      "currently it is only possible to set blob data with setBlob( idx, blob ) or setObject( idx, blob ). In the next release of the driver you can also use setObject( idx, stream, Types.BLOB ). setBinaryStream() is not possible because the driver has to 'know' that the data you want to set is for a lob column."
                      With that stated is there any way to get large oracle blobs working in JBoss with CMP?

                      • 8. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                        Andrew McCulloch Newbie

                        I am not sure if this is the appropriate place to post a patch but I have modified org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand and few of its child classes to check the underlying SQLType for "BLOB" and use the setBlob() method accordingly. This has only been tested on Oracle 8.1.7 with the Seropto driver but it works well there. This will solve the HeuristicRollbackException as noted above.

                        Thanks Will for pointing me in the right direction.

                        P.S.
                        Sorry if the diff is slightly modified but I had to remove some lines that were flagged as different because my IDE auto-formatted to the style of my employer.

                        • 9. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                          Will Ekiel Newbie

                          Thanks for following up on this issue and for taking the trouble of posting the resolution!

                          • 10. Re: HeuristicRollbackException when a BLOB > 4000 bytes
                            Subrahmanyam Newbie

                            Hi,
                            Can I check with you the code/exact guidelines to impliment CMP-BLOB with Oracle8i & JBoss2.4.4Tomcat3.2.3.

                            Thanx in advance

                            -Subbu