3 Replies Latest reply on Apr 20, 2005 10:15 AM by stundzig

    problem with '/' in ejb-name

    stundzig Newbie


      I'm currently migrating our EJB-apps from jboss 2.4.6 to 4.0.1RC2.

      We have many entity beans. For better overview we packaged them not only in java packages but also in packages in the ejb-name. So we have e.g. an WorkItemEntityBean with ejb-name 'worklist/WorkItemBean'. In the older jboss all works good, but in the newer version I get an SQLException e.g. on the findByPrimaryKey.

      13:31:26,059 DEBUG [worklist/WorkItemEntity#findByPrimaryKey] Executing SQL: SELECT t0_worklist/WorkItemEntity.id FROM WORKITEMENTITY t0_wor
      klist/WorkItemEntity WHERE t0_worklist/WorkItemEntity.id=?
      13:31:26,069 ERROR [worklist/WorkItemEntity#findByPrimaryKey] Find failed
      java.sql.SQLException: ORA-00933: SQL-Befehl wurde nicht korrekt beendet
       at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
       at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
       at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
       at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
       at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
       at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
       at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
       at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
       at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
       at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:296)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:206)

      Database is Oracle9i.

      If I change the ejb-name to 'WorkItemEntity' only, then it works as expected.

      13:35:04,002 DEBUG [WorkItemEntity#findByPrimaryKey] Executing SQL: SELECT t0_WorkItemEntity.id FROM WORKITEMENTITY t0_WorkItemEntity WHERE

      In the jbosscmp-jdbc.xml exists an entry tablename 'WorkItemEntity'. It's unchanged for each of the two alternatives of ejb-name.

      What can I do? Is it possible to have '/' in ejb-names?


        • 1. Re: problem with '/' in ejb-name
          stundzig Newbie


          I've researched this behaviour a bit and I found the following in e.g. JDBCFindByPrimaryKeyQuery line 56 (jboss4.0.1RC and 4.0.2RC1 too):

          String alias = aliasManager.getAlias(entity.getEntityName());

          The ejb-name of my entity is
          and therefore the alias can be
          This results in a SQL statement like:
          SELECT t0_worklist/WorkItemEntity.id FROM WORKITEMENTITY

          which isn't valid for Oracle JDBC driver.

          One solution could be to use the entity.getAbstractSchemaName(), but this is an optional field in CMP1.x. Another solution could by to extend the getAlias()-method to remove all illegal SQL-characters.

          Or did I missed something?

          I'm using CMP1.x Entity beans.


          • 2. Re: problem with '/' in ejb-name
            Scott Stark Master

            The ejb-2.1 spec states that the ejb-name must be a valid java identifier. This excludes the use of '/':

            10.3.13 The Bean Provider?s View of the Deployment Descriptor

            The persistent fields (cmp-fields) and relationships (cmr-fields) of an entity bean must be declared in the
            deployment descriptor.

            The deployment descriptor provides the following information about the abstract persistence schemas of entity beans and their container-managed relationships:
            ? An ejb-name element for each entity bean. The ejb-name must be a valid Java identifier and must be unique within the ejb-name elements of the ejb-jar file.
            ? An abstract-schema-name element for each entity bean. The
            abstract-schema-name must be a valid Java identifier and must be unique within the abstract-schema-name elements of the ejb-jar file. The abstract-schema-name element is used in the specification of EJB QL queries.

            • 3. Re: problem with '/' in ejb-name
              stundzig Newbie

              Hi scott,

              you are right. I was misled by the comment in the ejb_jar_2_0.dtd:

              The name for an entity bean with cmp-version 2.x must conform to the
              lexical rules for an NMTOKEN. The name for an entity bean with
              cmp-version 2.x must not be a reserved literal in EJB QL.

              It sounds like that 1.x beans must not conform to the rules for NMTOKEN.

              I will change my ejb-names now.