java.lang.StringIndexOutOfBoundsException

tip

Thrown by String methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the charAt method, this exception also is thrown when the index is equal to the size of the string.


rafael

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • The get method of CharacterType is calling java.lang.String.charAt(0) on a String instance that has zero length This resulted rom trying to load a mapped object from a Mysql 4.0.13 record that has a blank column Sep 4, 2003 8:55:27 AM net.sf.hibernate.impl.IteratorImpl next SEVERE: could not get next result java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94) java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94) rethrown as net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem: String index out of range: 0 at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:81) at test.TestHibernate.main(TestHibernate.java:94) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) ... 1 more
    via by Tim Schafer,
  • The get method of CharacterType is calling java.lang.String.charAt(0) on a String instance that has zero length This resulted rom trying to load a mapped object from a Mysql 4.0.13 record that has a blank column Sep 4, 2003 8:55:27 AM net.sf.hibernate.impl.IteratorImpl next SEVERE: could not get next result java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94) java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94) rethrown as net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem: String index out of range: 0 at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:81) at test.TestHibernate.main(TestHibernate.java:94) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) ... 1 more
    via by Tim Schafer,
  • Loop not executing more than once
    via Stack Overflow by Doha Kik
    ,
    • java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94)

    Users with the same issue

    Unknown visitor1 times, last one,
    linxiaolong
    1 times, last one,
    Hronom
    32257 times, last one,
    balintn
    4 times, last one,
    Unknown visitor1 times, last one,
    30 more bugmates