java.lang.IndexOutOfBoundsException

Hibernate JIRA | Karol Toompalu | 10 months ago
  1. 0

    When creating Blob with Hibernate, I get exception with files larger than Integer.MAX_VALUE bytes. Debugged the code and found that org.hibernate.engine.jdbc.BlobProxy returns negative value for stream length. Usage: session.getLobHelper().createBlob(InputStream stream, long length) I suggest that the cause is in StreamBackedBinaryStream.getLength(): long -> int -> long public long getLength() { return (int) length; } Currently using Hibernate 4.2, but saw the same kind of casting in Hibernate 5. Stack trace: java.lang.IndexOutOfBoundsException at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:255) at org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(AbstractJdbc2Statement.java:2890) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setBlob(WrappedPreparedStatement.java:787) at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$4$1.doBind(BlobTypeDescriptor.java:118) at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275) at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:57) at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2786) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3064) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3509) at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:364) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:356) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:277) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:328) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)

    Hibernate JIRA | 10 months ago | Karol Toompalu
    java.lang.IndexOutOfBoundsException
  2. 0

    When creating Blob with Hibernate, I get exception with files larger than Integer.MAX_VALUE bytes. Debugged the code and found that org.hibernate.engine.jdbc.BlobProxy returns negative value for stream length. Usage: session.getLobHelper().createBlob(InputStream stream, long length) I suggest that the cause is in StreamBackedBinaryStream.getLength(): long -> int -> long public long getLength() { return (int) length; } Currently using Hibernate 4.2, but saw the same kind of casting in Hibernate 5. Stack trace: java.lang.IndexOutOfBoundsException at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:255) at org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(AbstractJdbc2Statement.java:2890) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setBlob(WrappedPreparedStatement.java:787) at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$4$1.doBind(BlobTypeDescriptor.java:118) at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275) at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:57) at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2786) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3064) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3509) at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:364) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:356) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:277) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:328) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)

    Hibernate JIRA | 10 months ago | Karol Toompalu
    java.lang.IndexOutOfBoundsException
  3. 0

    Read bytes beginning is last delimiter position in binary file with java?

    Stack Overflow | 2 years ago | Zurix
    java.lang.IndexOutOfBoundsException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Why does FileInputReader.read() only reads 5 bytes at a time (Java)?

    Stack Overflow | 3 years ago | Andre
    java.lang.IndexOutOfBoundsException
  6. 0

    IndexOutOfBoundsException when trying to read MS Excel file using Apache POI-HSSF

    Stack Overflow | 8 years ago | Vlad Gudim
    java.lang.IndexOutOfBoundsException

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IndexOutOfBoundsException

      No message provided

      at java.io.FileInputStream.readBytes()
    2. Java RT
      FileInputStream.read
      1. java.io.FileInputStream.readBytes(Native Method)
      2. java.io.FileInputStream.read(FileInputStream.java:255)
      2 frames
    3. PostgreSQL JDBC Driver
      AbstractJdbc2Statement.setBlob
      1. org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(AbstractJdbc2Statement.java:2890)
      1 frame
    4. JBoss Application Server Connector
      WrappedPreparedStatement.setBlob
      1. org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setBlob(WrappedPreparedStatement.java:787)
      1 frame
    5. Hibernate
      SessionImpl.managedFlush
      1. org.hibernate.type.descriptor.sql.BlobTypeDescriptor$4$1.doBind(BlobTypeDescriptor.java:118)
      2. org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93)
      3. org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280)
      4. org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275)
      5. org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:57)
      6. org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2786)
      7. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3064)
      8. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3509)
      9. org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
      10. org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:364)
      11. org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:356)
      12. org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:277)
      13. org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:328)
      14. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
      15. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234)
      16. org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
      16 frames