5 Replies Latest reply on Apr 19, 2004 7:21 AM by sesques

    Bug in EJB QL compiler?

    mannef

      I think I may have stumbled across a bug in the EJB QL compiler. But being new to JBoss CMP, I was wondering whether I may have done something wrong.

      When trying to parse the following query, the deployment thread throws a NullPointerException at me:

      SELECT OBJECT(t) FROM TranslationError t WHERE t.originalLanguage = ?1 AND t.targetLanguage = ?2

      Is there anything wrong with this. The properties originalLanguage and targetLanguage contain references to another CMP entity bean.

      Cheers,
      Manne

        • 1. Re: Bug in EJB QL compiler?
          sesques

          Hi,

          Post the exact log or your code snippet.
          Not enough info to investigate.

          • 2. Re: Bug in EJB QL compiler?
            mannef

            Hi,

            Thanks for the reply - sorry about the terse info in my first post.

            Stepping through the JBoss code, I've found that the cause of the nullpointer is the fact that the getEntity() method in org.jboss.ejb.plugins.cmp.ejbql.ASTPath returns null, because the last object in the fieldList is neither an instance of CMRFieldBridge nor of EntityBridge, but of JDBCCMP2xFieldBridge. This causes an exception on line 323 in the class JDBCEJBQLCompiler.

            Looks like a bug to me (especially since this deploys without errors in Orion AS), but a snippet from the configuration of the EJB in question and the start of the stack trace I get follow below.

            Regards,
            Manne




            <ejb-name>TranslationErrorEJB</ejb-name>
            <local-home>com.zinesoft.translationerror.ejb.entity.TranslationErrorHome</local-home>
            com.zinesoft.translationerror.ejb.entity.TranslationError
            <ejb-class>com.zinesoft.translationerror.ejb.entity.TranslationErrorBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.String</prim-key-class>
            False
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>TranslationError</abstract-schema-name>
            <cmp-field>
            <field-name>originalLanguage</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>targetLanguage</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>incorrectTranslation</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>suggestedTranslation</field-name>
            </cmp-field>
            <cmp-field>
            The phrase in the original language
            <field-name>phrase</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <primkey-field>id</primkey-field>

            <query-method>
            <method-name>findByLanguages</method-name>
            <method-params>
            <method-param>
            com.zinesoft.translationerror.ejb.entity.Language
            </method-param>
            <method-param>
            com.zinesoft.translationerror.ejb.entity.Language
            </method-param>
            </method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(t) FROM TranslationError t WHERE t.originalLanguage = ?1 AND t.targetLanguage = ?2</ejb-ql>




            2004-04-14 21:51:40,093 ERROR [org.jboss.ejb.EntityContainer] Starting failed
            org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT OBJECT(t) FROM TranslationError t WHERE t.originalLanguage = ?1 AND t.targetLanguage = ?2'; - nested throwable: (java.lang.NullPointerException)
            at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:50)
            at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:59)
            ...

            • 3. Re: Bug in EJB QL compiler?
              sesques

              Forget the JBoss code.
              Your fields originalLanguage and targetLanguage are CMP fields, not CMR. So they are mapped to a column type in your database. How can you define a finder taking parameters which are references to another bean, and compare them to column types.
              For me, your finder can only work if originalLanguage and targetLanguage are CMR fields, not CMP.
              But perhaps you forgot to tell all the story, or I misunderstand something ?

              • 4. Re: Bug in EJB QL compiler?
                mannef

                Hi Sesques,

                Thanks for looking into this.

                The originalLanguage and targetLanguage fields (properties) are in fact references to other entity beans, not Strings or anything like that. Is there a problem with that?

                As I said, I'm new to JBoss CMP beans and wouldn't consider myself an expert on entity beans generally, so bear with me if I'm being silly.

                However, my code works fine in Orion AS, so I think this is either a bug in JBoss, or Orion provides functionality over the EJB spec. Imho JBoss should at least trap any error I may have made and produce a meaningful error message rather than stopping with a NullPointerException.

                Regards,
                Manne

                • 5. Re: Bug in EJB QL compiler?
                  sesques

                   

                  "ManneF" wrote:
                  Hi Sesques,

                  Thanks for looking into this.

                  The originalLanguage and targetLanguage fields (properties) are in fact references to other entity beans, not Strings or anything like that. Is there a problem with that?

                  As I said, I'm new to JBoss CMP beans and wouldn't consider myself an expert on entity beans generally, so bear with me if I'm being silly.

                  However, my code works fine in Orion AS, so I think this is either a bug in JBoss, or Orion provides functionality over the EJB spec. Imho JBoss should at least trap any error I may have made and produce a meaningful error message rather than stopping with a NullPointerException.

                  Regards,
                  Manne


                  I don't know Orion AS but I'm sure that each application server has its own fashion to handle CMR fields. The problem is not in your code, but in the descriptors.
                  Nomally, the relationships must be declared in ejb-jar.xml (names, roles, multiplicity and cmr fields) in a section tag, this is the EJB spec.
                  And additionnaly, the mapping between CMR fields and the database are described in the jbosscmp-jdbc.xml descriptor.
                  I agree 100% with you about the meaningful error message you get.
                  You should have a look to your relationships definitions. I don't know how do you gererate the descriptors, but have a look to the XDoclet documentation.
                  If you are in a dead end, post theses files on the forum.
                  Pascal