java.lang.IndexOutOfBoundsException

Hibernate JIRA | Karol Toompalu | 1 year ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  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 | 1 year 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 | 1 year ago | Karol Toompalu
    java.lang.IndexOutOfBoundsException
  3. 0

    Artifactory 5 tries to sync support bundles via the DB. Since these files can be very large, they can produce a failure and cause Artifactory to fail to start up. To reproduce: 1. Create an Artifatory HA 5 instance 2. In the $ARTIFACTORY_HOME/support directory, create a large bundle (for example fallocate -l 2G support-bundle-20170202-2153523-1486072432334.zip) 3. Restart the node under which the bundle was created and observe the failure Notice the error in the $ARTIFACTORY_HOME/logs/catalina/localhost-DATE.log: {noformat} 02-Feb-2017 21:57:06.143 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.artifactory.webapp.servlet.ArtifactoryHomeConfigListener java.lang.RuntimeException: Failed to start file sync to db: Failed to insert config 'artifactory.support.support-bundle-20170202-2153523-1486072432334.zip' to database. at org.artifactory.common.config.ConfigurationManagerImpl.startSync(ConfigurationManagerImpl.java:153) at org.artifactory.webapp.servlet.BasicConfigManagers.initHomes(BasicConfigManagers.java:74) at org.artifactory.webapp.servlet.BasicConfigManagers.initialize(BasicConfigManagers.java:56) at org.artifactory.webapp.servlet.ArtifactoryHomeConfigListener.contextInitialized(ArtifactoryHomeConfigListener.java:53) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.artifactory.common.config.db.ConfigUpdateException: Failed to insert config 'artifactory.support.support-bundle-20170202-2153523-1486072432334.zip' to database. at org.artifactory.common.config.db.ConfigsDataAccessObject.setConfig(ConfigsDataAccessObject.java:142) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.fileToDb(ConfigWrapperImpl.java:275) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.modifyInternal(ConfigWrapperImpl.java:227) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.modifiedWithRetry(ConfigWrapperImpl.java:208) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.modifiedWithRetry(ConfigWrapperImpl.java:211) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.modifiedWithRetry(ConfigWrapperImpl.java:211) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.modifiedWithRetry(ConfigWrapperImpl.java:211) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.initialize(ConfigWrapperImpl.java:70) at org.artifactory.common.config.wrappers.ConfigWrapperImpl.<init>(ConfigWrapperImpl.java:58) at org.artifactory.common.config.ConfigurationManagerImpl.registerFolder(ConfigurationManagerImpl.java:245) at org.artifactory.common.config.ConfigurationManagerImpl.registerSharedFiles(ConfigurationManagerImpl.java:212) at org.artifactory.common.config.ConfigurationManagerImpl.startFileSync(ConfigurationManagerImpl.java:187) at org.artifactory.common.config.ConfigurationManagerImpl.startSync(ConfigurationManagerImpl.java:149) ... 16 more Caused by: java.sql.SQLException: Error reading from InputStream java.lang.IndexOutOfBoundsException at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872) at com.mysql.jdbc.PreparedStatement.readblock(PreparedStatement.java:2712) at com.mysql.jdbc.PreparedStatement.streamToBytes(PreparedStatement.java:4514) at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2238) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2092) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2049) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2034) at org.artifactory.common.config.db.TemporaryDBChannel.executeUpdate(TemporaryDBChannel.java:62) at org.artifactory.common.config.db.ConfigsDataAccessObject.setConfig(ConfigsDataAccessObject.java:139) ... 28 more Caused by: java.lang.IndexOutOfBoundsException at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:255) at com.mysql.jdbc.PreparedStatement.readblock(PreparedStatement.java:2710) ... 35 more {noformat}

    JFrog JIRA | 3 months ago | Arturo Aparicio
    java.lang.RuntimeException: Failed to start file sync to db: Failed to insert config 'artifactory.support.support-bundle-20170202-2153523-1486072432334.zip' to database.
  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

    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