4 Replies Latest reply: Jul 20, 2011 12:30 PM by JamesSutherland RSS

    IndexOutOfBoundsException

    684687
      Hi !

      I get an IndexOutOfBoundsException while executing this JPQL:

      SELECT DISTINCT
      entity
      FROM
      Fahrt entity
      LEFT JOIN entity.allHaltepunktIsthpkt t1
      LEFT JOIN t1.reihungAbf t2
      LEFT JOIN t1.reihungAnk t3
      LEFT JOIN t2.allReihungFahrzeug t4
      LEFT JOIN t4.fahrzeugwerte t5
      LEFT JOIN t3.allReihungFahrzeug t6
      LEFT JOIN t6.fahrzeugwerte t7
      WHERE
      entity.verkehrstag <= :entity_verkehrstag_0 AND
      entity.kennzeichenArchivierung IS NULL AND
      ( t2.verkehrstag <= :t2_verkehrstag_1 OR t2.verkehrstag IS NULL) AND
      ( t3.verkehrstag <= :t3_verkehrstag_2 OR t3.verkehrstag IS NULL) AND
      ( t5.zeitpunktAktuellBis <= :t5_zeitpunktAktuellBis_3 OR t5.zeitpunktAktuellBis IS NULL) AND
      ( t7.zeitpunktAktuellBis <= :t7_zeitpunktAktuellBis_4 OR t7.zeitpunktAktuellBis IS NULL)

      values={t3_verkehrstag_2=Fri Jan 07 00:00:00 CET 2011, t2_verkehrstag_1=Fri Jan 07 00:00:00 CET 2011, t5_zeitpunktAktuellBis_3=Fri Jan 07 00:00:00 CET 2011, entity_verkehrstag_0=Fri Jan 07 00:00:00 CET 2011, t7_zeitpunktAktuellBis_4=Fri Jan 07 00:00:00 CET 2011}

      hints=[eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt.reihungAbf.allReihungFahrzeug.fahrzeugwerte, eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt, eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt.reihungAbf.allReihungFahrzeug, eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt.reihungAnk, eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt.reihungAnk.allReihungFahrzeug.fahrzeugwerte, eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt.reihungAnk.allReihungFahrzeug, eclipselink.left-join-fetch=entity.allHaltepunktIsthpkt.reihungAbf]


      The execution of the jpql produce the following:
      Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.QueryException

      Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.IndexOutOfBoundsException: Index: 3, Size: 2].

      Internal Exception: java.lang.IndexOutOfBoundsException: Index: 3, Size: 2

      Query: ReadAllQuery(referenceClass=Fahrt sql="SELECT DISTINCT t0.ID, t0."BAHNHOF_ABFAHRT_MP_CODE", t0."BAHNHOF_ABFAHRT_MP_DIENSTSTEL3", t0."BAHNHOF_ABFAHRT_MP_TEXT", t0."BAHNHOF_ABFAHRT_MP_UNTERNEHMEN", t0."BAHNHOF_ABFAHRT_UIC", t0."BAHNHOF_ABFAHRT_UIC_LAND", t0."BAHNHOF_ABFAHRT_ZEITPUNKT", t0."BAHNHOF_ANKUNFT_MP_CODE", t0."BAHNHOF_ANKUNFT_MP_DIENSTSTE10", t0."BAHNHOF_ANKUNFT_MP_TEXT", t0."BAHNHOF_ANKUNFT_MP_UNTERNEHMEN", t0."BAHNHOF_ANKUNFT_UIC", t0."BAHNHOF_ANKUNFT_UIC_LAND", t0."BAHNHOF_ANKUNFT_ZEITPUNKT", t0."BESTELLER_EVU", t0.CREATE_TIMESTAMP, t0.CREATE_USER, t0."FAHRT_TYP", t0."FAHRTNUMMER", t0."INDIKATOR_BLS", t0."KENNZEICHEN_ARCHIVIERUNG", t0.OPTLOCK, t0."RANGIER_EVU", t0."STRECKEN_EVU", t0."TRAKTION_EVU", t0.UPDATE_TIMESTAMP, t0.UPDATE_USER, t0."VERKEHRSTAG", t0."VERKEHRSTAG_HAFEN", t0.STATE_ID, t0.STATE_ID_ZOLL FROM T_FAHRT t0 LEFT OUTER JOIN T_HPKT t2 ON (t2.FAHRT_ID_ISTHPKT = t0.ID) LEFT OUTER JOIN T_REI t1 ON (t1.ID = t2.REI_ID_ABF) LEFT OUTER JOIN T_RFAZ t5 ON (t5.REI_ID = t1.ID) LEFT OUTER JOIN T_FAW t4 ON (t4.ID = t5.FAW_ID) LEFT OUTER JOIN T_REI t3 ON (t3.ID = t2.REI_ID_ANK) LEFT OUTER JOIN T_RFAZ t7 ON (t7.REI_ID = t3.ID) LEFT OUTER JOIN T_FAW t6 ON (t6.ID = t7.FAW_ID) WHERE ((((((t0."VERKEHRSTAG" <= ?) AND (t0."KENNZEICHEN_ARCHIVIERUNG" IS NULL)) AND ((t1."VERKEHRSTAG" <= ?) OR (t1."VERKEHRSTAG" IS NULL))) AND ((t3."VERKEHRSTAG" <= ?) OR (t3."VERKEHRSTAG" IS NULL))) AND ((t4."ZEITPUNKT_AKTUELL_BIS" <= ?) OR (t4."ZEITPUNKT_AKTUELL_BIS" IS NULL))) AND ((t6."ZEITPUNKT_AKTUELL_BIS" <= ?) OR (t6."ZEITPUNKT_AKTUELL_BIS" IS NULL)))")

      at org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1542)
      at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:589)
      at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:824)
      at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:537)
      at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:778)
      at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
      at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:383)
      at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1126)
      at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2842)
      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1521)
      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1503)
      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1477)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:484)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:741)


      Does anybody have an idea why the exception occures?
        • 1. Re: IndexOutOfBoundsException
          cdelahun
          Hello,

          Can you try simplifying the query to find the where the problem might be? Also, please post the stack trace for the IndexOutOfBoundsException internal exception; the stack posted only shows the QueryException wraping the actual exception.

          Best Regards,
          Chris
          • 2. Re: IndexOutOfBoundsException
            684687
            Here is the full callstack:

            Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.QueryException
            Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.IndexOutOfBoundsException: Index: 3, Size: 2].
            Internal Exception: java.lang.IndexOutOfBoundsException: Index: 3, Size: 2

            Query: ReadAllQuery(referenceClass=Fahrt sql="SELECT DISTINCT t0.ID, t0."BAHNHOF_ABFAHRT_MP_CODE", t0."BAHNHOF_ABFAHRT_MP_DIENSTSTEL3", t0."BAHNHOF_ABFAHRT_MP_TEXT", t0."BAHNHOF_ABFAHRT_MP_UNTERNEHMEN", t0."BAHNHOF_ABFAHRT_UIC", t0."BAHNHOF_ABFAHRT_UIC_LAND", t0."BAHNHOF_ABFAHRT_ZEITPUNKT", t0."BAHNHOF_ANKUNFT_MP_CODE", t0."BAHNHOF_ANKUNFT_MP_DIENSTSTE10", t0."BAHNHOF_ANKUNFT_MP_TEXT", t0."BAHNHOF_ANKUNFT_MP_UNTERNEHMEN", t0."BAHNHOF_ANKUNFT_UIC", t0."BAHNHOF_ANKUNFT_UIC_LAND", t0."BAHNHOF_ANKUNFT_ZEITPUNKT", t0."BESTELLER_EVU", t0.CREATE_TIMESTAMP, t0.CREATE_USER, t0."FAHRT_TYP", t0."FAHRTNUMMER", t0."INDIKATOR_BLS", t0."KENNZEICHEN_ARCHIVIERUNG", t0.OPTLOCK, t0."RANGIER_EVU", t0."STRECKEN_EVU", t0."TRAKTION_EVU", t0.UPDATE_TIMESTAMP, t0.UPDATE_USER, t0."VERKEHRSTAG", t0."VERKEHRSTAG_HAFEN", t0.STATE_ID, t0.STATE_ID_ZOLL FROM T_FAHRT t0 LEFT OUTER JOIN T_HPKT t2 ON (t2.FAHRT_ID_ISTHPKT = t0.ID) LEFT OUTER JOIN T_REI t1 ON (t1.ID = t2.REI_ID_ABF) LEFT OUTER JOIN T_RFAZ t5 ON (t5.REI_ID = t1.ID) LEFT OUTER JOIN T_FAW t4 ON (t4.ID = t5.FAW_ID) LEFT OUTER JOIN T_REI t3 ON (t3.ID = t2.REI_ID_ANK) LEFT OUTER JOIN T_RFAZ t7 ON (t7.REI_ID = t3.ID) LEFT OUTER JOIN T_FAW t6 ON (t6.ID = t7.FAW_ID) WHERE ((((((t0."VERKEHRSTAG" <= ?) AND (t0."KENNZEICHEN_ARCHIVIERUNG" IS NULL)) AND ((t1."VERKEHRSTAG" <= ?) OR (t1."VERKEHRSTAG" IS NULL))) AND ((t3."VERKEHRSTAG" <= ?) OR (t3."VERKEHRSTAG" IS NULL))) AND ((t4."ZEITPUNKT_AKTUELL_BIS" <= ?) OR (t4."ZEITPUNKT_AKTUELL_BIS" IS NULL))) AND ((t6."ZEITPUNKT_AKTUELL_BIS" <= ?) OR (t6."ZEITPUNKT_AKTUELL_BIS" IS NULL)))")

            at org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1542)
            at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:589)
            at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:824)
            at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:537)
            at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:778)
            at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
            at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:383)
            at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1126)
            at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2842)
            at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1521)
            at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1503)
            at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1477)
            at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:484)
            at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:741)
            at xxx.core.dao.DAOKernel.findByNamedParams(DAOKernel.java:634)
            at xxx.core.dao.DAOKernel.filterInternal(DAOKernel.java:478)
            at xxx.core.dao.DAOKernel.filter(DAOKernel.java:379)
            at xxx.core.dao.DAOKernel.filter(DAOKernel.java:341)
            at xxx.core.dao.BaseDAO.filter(BaseDAO.java:47)
            at xxx.core.dao.DAO.filter(DAO.java:94)
            at de.xxx.core.dao.FahrtBaseDAO.filterVO(FahrtBaseDAO.java:126)
            at de.xxx.core.service.ArchivierungServiceProduktionSpringDBTest.getAlleZuArchivierendenFahrten(ArchivierungServiceProduktionSpringDBTest.java:912)
            at de.xxx.core.service.ArchivierungServiceProduktionSpringDBTest.testQueryAlleZuArchivierendenFahrtenOutOfBounds(ArchivierungServiceProduktionSpringDBTest.java:868)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
            at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
            at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
            at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
            at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
            at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
            at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
            at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
            at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
            at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
            at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
            at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
            Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 2
            at java.util.ArrayList.add(Unknown Source)
            at org.eclipse.persistence.internal.queries.JoinedAttributeManager.addExpressionAndBaseToGroupedList(JoinedAttributeManager.java:828)
            at org.eclipse.persistence.internal.queries.JoinedAttributeManager.prepareJoinExpressions(JoinedAttributeManager.java:780)
            at org.eclipse.persistence.mappings.ForeignReferenceMapping.prepareNestedJoins(ForeignReferenceMapping.java:660)
            at org.eclipse.persistence.internal.queries.JoinedAttributeManager.computeNestedQueriesForJoinedExpressions(JoinedAttributeManager.java:288)
            at org.eclipse.persistence.internal.queries.JoinedAttributeManager.computeJoiningMappingQueries(JoinedAttributeManager.java:308)
            at org.eclipse.persistence.queries.ObjectLevelReadQuery.prepare(ObjectLevelReadQuery.java:1931)
            at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:616)
            at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:577)
            ... 44 more
            • 3. Re: IndexOutOfBoundsException
              870559
              Hi,

              Did you got the solution to this?

              I am also getting the same exception.

              Thanks and Regards,
              Ankur Singhal
              • 4. Re: IndexOutOfBoundsException
                JamesSutherland
                Please log a bug and include your JPQL and model.

                The exception is caused by the order of the joins in the from clause, so you could try removing them, or re-ordering them.

                ---
                James : http://www.eclipse.org/eclipselink/