5 Replies Latest reply on Nov 27, 2002 7:50 AM by 376059

    EJB QL : EJBException StringIndexOutOfBoundsException

    376059
      Hi,

      I always get the following two Errors, trying to do something with EJB QL
      using the Embedded OC4J Server.

      The DB is a IBM DB2 UDB7.2
      The version of JDev is 9.0.3.1035

      Without using EJB QL (findByPrimaryKey) everything works fine

      I do not know if JDev itself is using the start_oc4j.bat, but I set this command line:
      java.exe -Denable.ejbql=true -jar oc4j.jar

      The EJB QL statement from my ejb-jar.xml is:

      <query>
      <query-method>
      <method-name>findByKuerzel</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>select distinct objekt(k) from KK k where k.kk_kuerzel = ?1</ejb-ql>
      </query>


      ERROR MESSAGE :

      javax.ejb.EJBException: nested exception is: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1

      java.lang.String java.lang.String.substring(int, int)

      String.java:1525

      void com.sun.ejb.sqlgen.SQLGenerator.generateCreateTableQuery()

      SQLGenerator.java:530

      void com.sun.ejb.sqlgen.SQLGenerator.<init>(com.sun.enterprise.deployment.PersistenceDescriptor, java.lang.String, com.sun.ejb.sqlgen.SQLTypeMapper, com.sun.ejb.sqlgen.DBMetaData)

      SQLGenerator.java:240

      void com.sun.ejb.sqlgen.SQLGenerator.generateSQL(com.sun.enterprise.deployment.EjbCMPEntityDescriptor, boolean, com.sun.ejb.sqlgen.DBMetaData, com.sun.ejb.sqlgen.SQLTypeMapper)

      SQLGenerator.java:360

      void com.sun.ejb.sqlgen.SQLGenerator.generateSQL(com.sun.enterprise.deployment.EjbBundleDescriptor, com.sun.enterprise.deployment.ResourceReferenceDescriptor, boolean, com.sun.ejb.sqlgen.DBInfo)

      SQLGenerator.java:309

      void com.evermind.server.ejb.deployment.EJBPackage.translateEjbqlQeries()

      EJBPackage.java:2100

      void com.evermind.server.ejb.compilation.Compilation.translateEjbqlQeries()

      Compilation.java:140

      void com.evermind.server.ejb.compilation.Compilation.compile()

      Compilation.java:178

      void com.evermind.server.ejb.EJBContainer.postInit(com.evermind.server.ejb.EJBContainerConfig, com.evermind.server.administration.ApplicationInstallation)

      EJBContainer.java:551

      void com.evermind.server.Application.postInit(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)

      Application.java:431

      void com.evermind.server.Application.setConfig(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)

      Application.java:136

      void com.evermind.server.ApplicationServer.addApplication(com.evermind.server.ApplicationConfig, com.evermind.server.Application, com.evermind.server.administration.ApplicationInstallation)

      ApplicationServer.java:1635

      com.evermind.server.Application com.evermind.server.ApplicationServer.getApplication(java.lang.String, com.evermind.util.ErrorHandler)

      ApplicationServer.java:2130

      void com.evermind.server.rmi.RMIConnection.run(java.lang.Thread)

      RMIConnection.java:396

      void com.evermind.server.rmi.RMIConnection.run()

      RMIConnection.java:275

      void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()

      PooledExecutor.java:803

      void java.lang.Thread.run()

      Thread.java:484

      javax.ejb.EJBException: nested exception is: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

      void com.sun.ejb.sqlgen.SQLGenerator.<init>(com.sun.enterprise.deployment.PersistenceDescriptor, java.lang.String, com.sun.ejb.sqlgen.SQLTypeMapper, com.sun.ejb.sqlgen.DBMetaData)

      SQLGenerator.java:255

      void com.sun.ejb.sqlgen.SQLGenerator.generateSQL(com.sun.enterprise.deployment.EjbCMPEntityDescriptor, boolean, com.sun.ejb.sqlgen.DBMetaData, com.sun.ejb.sqlgen.SQLTypeMapper)

      SQLGenerator.java:360

      void com.sun.ejb.sqlgen.SQLGenerator.generateSQL(com.sun.enterprise.deployment.EjbBundleDescriptor, com.sun.enterprise.deployment.ResourceReferenceDescriptor, boolean, com.sun.ejb.sqlgen.DBInfo)

      SQLGenerator.java:309

      void com.evermind.server.ejb.deployment.EJBPackage.translateEjbqlQeries()

      EJBPackage.java:2100

      void com.evermind.server.ejb.compilation.Compilation.translateEjbqlQeries()

      Compilation.java:140

      void com.evermind.server.ejb.compilation.Compilation.compile()

      Compilation.java:178

      void com.evermind.server.ejb.EJBContainer.postInit(com.evermind.server.ejb.EJBContainerConfig, com.evermind.server.administration.ApplicationInstallation)

      EJBContainer.java:551

      void com.evermind.server.Application.postInit(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)

      Application.java:431

      void com.evermind.server.Application.setConfig(com.evermind.server.ApplicationConfig, com.evermind.server.administration.ApplicationInstallation)

      Application.java:136

      void com.evermind.server.ApplicationServer.addApplication(com.evermind.server.ApplicationConfig, com.evermind.server.Application, com.evermind.server.administration.ApplicationInstallation)

      ApplicationServer.java:1635

      com.evermind.server.Application com.evermind.server.ApplicationServer.getApplication(java.lang.String, com.evermind.util.ErrorHandler)

      ApplicationServer.java:2130

      void com.evermind.server.rmi.RMIConnection.run(java.lang.Thread)

      RMIConnection.java:396

      void com.evermind.server.rmi.RMIConnection.run()

      RMIConnection.java:275

      void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()

      PooledExecutor.java:803

      void java.lang.Thread.run()

      Thread.java:484

      Error compiling C:\Programme\Jdev903\jdev\mywork\myApp\classes: Error translating EJBQL: javax.ejb.EJBException: nested exception is: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        • 1. re:EJB QL : EJBException StringIndexOutOfBoundsException
          Avi Abrami
          Hi Klaus,
          I don't know if it's a typo, but it's spelt "object" and not "objekt".
          Also -- and I'm only guessing here -- I don't think "distinct"
          is allowed. Remember, OC4J supports EJB 2.0 (not EJB 2.1). I don't
          have any experience with EJB-QL, so the above may be wrong.

          Hope this helps you.

          Good Luck,
          Avi.
          • 2. re:EJB QL : EJBException StringIndexOutOfBoundsException
            Steve Button-Oracle
            Hi Klaus,
            I don't know if it's a typo, but it's spelt "object" and not "objekt".
            Also -- and I'm only guessing here -- I don't think "distinct"
            is allowed. Remember, OC4J supports EJB 2.0 (not EJB 2.1). I don't
            have any experience with EJB-QL, so the above may be wrong.
            Hope this helps you.
            Good Luck,
            Avi.
            Good suggestion Avi - it is OBJECT not objekt. Distinct is a valid keyword in EJBQL in the EJB 2.0 spec.

            Klaus - what version of OC4J are you using? I just tried deploying a bean with query containing "OBJEKT" against the 903 version and it reported the error message below.

            Also - with 903, you no longer need to specify the system property (enable.ejbql) to make EJBQL work. That was a requirement before we released our J2EE 1.3 compatible version and is no longer necessary with 903.


            uto-unpacking D:\java\oc4j-903-production\j2ee\home\applications\empbft-ear.ear... done.
            Auto-deploying empbft-ear (Assembly had been updated)...
            Encountered "objekt" at line 1, column 8.
            Was expecting one of:
            "OBJECT" ...
            "DISTINCT" ...
            "IdentificationVar" ...

            EJB QL statement : 'select objekt(e) from Employee e, in (e.benefits) b where b.benefitId=?1'
            EJB QL method : public abstract java.util.Collection empbft.component.employee.ejb20.EmployeeLocalHome.findByBenefitId(java.lang.Long) throws javax.ejb.FinderException

                 at com.sun.ejb.ejbql.parser.EjbQLParser.parse(EjbQLParser.java:224)
                 at com.sun.ejb.ejbql.EjbQLDriver.parse(EjbQLDriver.java:86)
                 at com.sun.ejb.sqlgen.SQLGenerator.generateSQLForEjbQLQueries(SQLGenerator.java:704)
                 at com.sun.ejb.sqlgen.SQLGenerator.generateSQL(SQLGenerator.java:334)
                 at com.evermind.server.ejb.deployment.EJBPackage.translateEjbqlQeries(EJBPackage.java:2100)
                 at com.evermind.server.ejb.compilation.Compilation.translateFatal Error: Error translating EJBQL: Encountered "objekt" at line 1, column 8.
            Was expecting one of:
            "OBJECT" ...
            "DISTINCT" ...
            "IdentificationVar" ...

            -steve-
            • 3. re:EJB QL : EJBException StringIndexOutOfBoundsException
              Steve Button-Oracle
              <ejb-ql>select distinct objekt(k) from KK k where k.kk_kuerzel = ?1</ejb-ql>
              Klaus - also KK here needs to match the abstract-persistence-schema attribute you gave to the bean. Do you have a bean tagged with the APS value of "KK".

              -steve-
              • 4. re:EJB QL : EJBException StringIndexOutOfBoundsException
                376059
                Of course ist must be OBJECT not objekt,

                but after correcting this misspelling I4m getting
                still the same error.
                • 5. re:EJB QL : EJBException StringIndexOutOfBoundsException
                  376059
                  <ejb-ql>select distinct objekt(k) from KK k where k.kk_kuerzel = ?1</ejb-ql>
                  Klaus - also KK here needs to match the abstract-persistence-schema attribute you gave to the bean. Do you have a bean tagged with the APS value of "KK".
                  -steve-
                  Yes there ist an EntityBean KK with the APS "KK".