java.lang.ArrayIndexOutOfBoundsException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Hi, when i use the auto ddl feature (hibernate.hbm2ddl.auto = update) , hibernate throws an error like: 11:13:08,328 ERROR SchemaUpdate:167 - could not complete schema update java.lang.ArrayIndexOutOfBoundsException: 2 at org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseMetadata.java:147) at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:935) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:144) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at com.db4o.replication.hibernate.MetaDataTablesCreator.createTables(MetaDataTablesCreator.java:60) at com.db4o.replication.hibernate.HibernateReplicationProviderImpl.<init>(HibernateReplicationProviderImpl.java:155) at com.db4o.replication.hibernate.HibernateReplicationProviderImpl.<init>(HibernateReplicationProviderImpl.java:137) at com.db4o.replication.Replication.wrap(Replication.java:104) at com.db4o.replication.Replication.begin(Replication.java:46) at com.db4o.replication.Replication.begin(Replication.java:57) at objectstore.ext.cache.CacheServer.main(CacheServer.java:103) I found something strange in the following class: package org.hibernate.tool.hbm2ddl; ........................... public class DatabaseMetadata { ............................. public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { if ( getTableMetadata( (String) key, null, null ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) {<--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! whats about index 0 !!!--> return getTableMetadata(strings[2], strings[1], strings[2]) != null; } else if (strings.length==2) { <---- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! whats about index 0 !!!--> return getTableMetadata(strings[2], strings[1], null) != null; } } } return false; } } Regards, Martin Kraus
    via by Martin Kraus,
  • Hi, when i use the auto ddl feature (hibernate.hbm2ddl.auto = update) , hibernate throws an error like: 11:13:08,328 ERROR SchemaUpdate:167 - could not complete schema update java.lang.ArrayIndexOutOfBoundsException: 2 at org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseMetadata.java:147) at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:935) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:144) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at com.db4o.replication.hibernate.MetaDataTablesCreator.createTables(MetaDataTablesCreator.java:60) at com.db4o.replication.hibernate.HibernateReplicationProviderImpl.<init>(HibernateReplicationProviderImpl.java:155) at com.db4o.replication.hibernate.HibernateReplicationProviderImpl.<init>(HibernateReplicationProviderImpl.java:137) at com.db4o.replication.Replication.wrap(Replication.java:104) at com.db4o.replication.Replication.begin(Replication.java:46) at com.db4o.replication.Replication.begin(Replication.java:57) at objectstore.ext.cache.CacheServer.main(CacheServer.java:103) I found something strange in the following class: package org.hibernate.tool.hbm2ddl; ........................... public class DatabaseMetadata { ............................. public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { if ( getTableMetadata( (String) key, null, null ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) {<--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! whats about index 0 !!!--> return getTableMetadata(strings[2], strings[1], strings[2]) != null; } else if (strings.length==2) { <---- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! whats about index 0 !!!--> return getTableMetadata(strings[2], strings[1], null) != null; } } } return false; } } Regards, Martin Kraus
    via by Martin Kraus,
  • Using a windows XP professional PC, I am using the SchemaUpdate (<property name="hibernate.hbm2ddl.auto" value="update" />) to both update and create a database (Latest version of Derby) and I got a ArrayIndexOutOfBoundsException because there is an error in the following method: public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { if ( getTableMetadata( (String) key, null, null ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) { return getTableMetadata(strings[2], strings[1], strings[2]) != null; } else if (strings.length==2) { return getTableMetadata(strings[2], strings[1], null) != null; } } } return false; } The indexes are wrong they should start from zero. strings[2],strings[1]. The correct implementation should be public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { if ( getTableMetadata( (String) key, null, null ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) { return getTableMetadata(strings[1], strings[0], strings[2]) != null; } else if (strings.length==2) { return getTableMetadata(strings[1], strings[0], null) != null; } } } return false; } The stack trace is: 09:35:14,481 ERROR SchemaUpdate:167 - could not complete schema update java.lang.ArrayIndexOutOfBoundsException: 2 at org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseMetadata.java:147) at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:935) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:144) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:414) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:575) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at com.motorola.nsm.common.cm.nodemanager.bl.NodeMgrBean.getInstance(NodeMgrBean.java:96) at com.motorola.nsm.common.cm.nodemanager.bl.NodeMgrBean.getNode(NodeMgrBean.java:186) at com.motorola.nsm.common.cm.nodemanager.bl.NodeMgrBean.print(NodeMgrBean.java:864) at com.motorola.nsm.common.cm.nodemanager.bl.CLIClient.main(CLIClient.java:12)
    via by Jose Vargas,
  • Using a windows XP professional PC, I am using the SchemaUpdate (<property name="hibernate.hbm2ddl.auto" value="update" />) to both update and create a database (Latest version of Derby) and I got a ArrayIndexOutOfBoundsException because there is an error in the following method: public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { if ( getTableMetadata( (String) key, null, null ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) { return getTableMetadata(strings[2], strings[1], strings[2]) != null; } else if (strings.length==2) { return getTableMetadata(strings[2], strings[1], null) != null; } } } return false; } The indexes are wrong they should start from zero. strings[2],strings[1]. The correct implementation should be public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { if ( getTableMetadata( (String) key, null, null ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) { return getTableMetadata(strings[1], strings[0], strings[2]) != null; } else if (strings.length==2) { return getTableMetadata(strings[1], strings[0], null) != null; } } } return false; } The stack trace is: 09:35:14,481 ERROR SchemaUpdate:167 - could not complete schema update java.lang.ArrayIndexOutOfBoundsException: 2 at org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseMetadata.java:147) at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:935) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:144) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:414) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:575) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at com.motorola.nsm.common.cm.nodemanager.bl.NodeMgrBean.getInstance(NodeMgrBean.java:96) at com.motorola.nsm.common.cm.nodemanager.bl.NodeMgrBean.getNode(NodeMgrBean.java:186) at com.motorola.nsm.common.cm.nodemanager.bl.NodeMgrBean.print(NodeMgrBean.java:864) at com.motorola.nsm.common.cm.nodemanager.bl.CLIClient.main(CLIClient.java:12)
    via by Jose Vargas,
    • java.lang.ArrayIndexOutOfBoundsException: 2 at org.hibernate.tool.hbm2ddl.DatabaseMetadata.isTable(DatabaseMetadata.java:147) at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:935) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:144) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at com.db4o.replication.hibernate.MetaDataTablesCreator.createTables(MetaDataTablesCreator.java:60) at com.db4o.replication.hibernate.HibernateReplicationProviderImpl.<init>(HibernateReplicationProviderImpl.java:155) at com.db4o.replication.hibernate.HibernateReplicationProviderImpl.<init>(HibernateReplicationProviderImpl.java:137) at com.db4o.replication.Replication.wrap(Replication.java:104) at com.db4o.replication.Replication.begin(Replication.java:46) at com.db4o.replication.Replication.begin(Replication.java:57) at objectstore.ext.cache.CacheServer.main(CacheServer.java:103)
    No Bugmate found.