6 Replies Latest reply on Oct 30, 2004 12:01 AM by dab

    EJB QL Parsing problem

    dab

      Can anyone point out what must be quite obvious:

      This is an error message from the console concerning the failure to
      parse a query. What's wrong with the query? Note that there is a CMP
      field called 'location'. with a getter and a setter. The problem seems
      to be syntactic..?

      ...
      Caused by: org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement

      'SELECT OBJECT(c) FROM ControlLogix AS c WHERE c.location = ?1'; -

      nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "c.location" at line 1, column 49.

      Was expecting one of:
      "NOT" ...
      "(" ...
      <COLLECTION_VALUED_PATH> ...
      <STRING_VALUED_PATH> ...
      "CONCAT" ...
      "SUBSTRING" ...
      <BOOLEAN_VALUED_PATH> ...
      <DATETIME_VALUED_PATH> ...
      <ENTITY_VALUED_PATH> ...
      <IDENTIFICATION_VARIABLE> ...
      <NUMERIC_VALUED_PATH> ...
      "LENGTH" ...
      "LOCATE" ...
      "ABS" ...
      "SQRT" ...
      "MOD" ...

        • 1. Re: EJB QL Parsing problem
          raist_majere

          Is "location" a CMP field of ControlLogix? Can you provide the ejb-jar.xml file?

          • 2. Re: EJB QL Parsing problem
            ivanlc

            Hi,

            try removing the "AS" from
            SELECT OBJECT(c) FROM ControlLogix AS c WHERE c.location = ?1

            ie.

            SELECT OBJECT(c) FROM ControlLogix c WHERE c.location = ?1

            Cheers,
            Ivan

            • 3. Re: EJB QL Parsing problem
              dab

              ivanlc: Thanks for the suggestion regarding removal of AS. Unfortunately it didn't make a difference.

              Raist_Majere: Here is my deployment descriptor. Many thanks for
              your interest.

              <?xml version="1.0" encoding="UTF-8"?>

              <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

              <ejb-jar >

              <![CDATA[No Description.]]>
              <display-name>Generated by XDoclet</display-name>

              <enterprise-beans>

              <!-- Entity Beans -->

              <![CDATA[The EJB representing the Rockwell ControlLogix 5550 PLC.]]>

              <ejb-name>ControlLogix</ejb-name>

              com.generic.ControlLogixHome
              com.generic.ControlLogix
              <local-home>com.generic.ControlLogixLocalHome</local-home>
              com.generic.ControlLogixLocal

              <ejb-class>com.generic.ControlLogixCMP</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>ControlLogix</abstract-schema-name>
              <cmp-field >
              <![CDATA[Gets the location of the PLC.]]>
              <field-name>location</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[Gets the name of the plc.]]>
              <field-name>name</field-name>
              </cmp-field>
              <primkey-field>name</primkey-field>

              <resource-ref >
              <res-ref-name>datadource</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              </resource-ref>


              <query-method>
              <method-name>findByName</method-name>
              <method-params>
              <method-param>java.lang.String</method-param>
              </method-params>
              </query-method>
              <ejb-ql><![CDATA[SELECT OBJECT(c) FROM ControlLogix c WHERE c.name = ?1]]></ejb-ql>


              <query-method>
              <method-name>findByLocation</method-name>
              <method-params>
              <method-param>com.generic.MyPath</method-param>
              </method-params>
              </query-method>
              <ejb-ql><![CDATA[SELECT OBJECT(c) FROM ControlLogix c WHERE c.location = ?1]]></ejb-ql>


              <query-method>
              <method-name>findAll</method-name>
              <method-params>
              </method-params>
              </query-method>
              <ejb-ql><![CDATA[SELECT OBJECT(c) FROM ControlLogix AS c]]></ejb-ql>

              <!-- Write a file named ejb-finders-ControlLogixBean.xml if you want to define extra finders. -->


              <!--
              To add entity beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called entity-beans.xml that contains
              the markup for those beans.
              -->

              <!-- Message Driven Beans -->
              <!--
              To add message driven beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called message-driven-beans.xml that contains
              the <message-driven></message-driven> markup for those beans.
              -->

              </enterprise-beans>

              <!-- Relationships -->

              <!-- Assembly Descriptor -->
              <!--
              To specify your own assembly descriptor info here, add a file to your
              XDoclet merge directory called assembly-descriptor.xml that contains
              the <assembly-descriptor></assembly-descriptor> markup.
              -->

              <assembly-descriptor >
              <!--
              To specify additional security-role elements, add a file in the merge
              directory called ejb-security-roles.xml that contains them.
              -->

              <!-- method permissions -->
              <!--
              To specify additional method-permission elements, add a file in the merge
              directory called ejb-method-permissions.ent that contains them.
              -->

              <!-- finder permissions -->

              <method-permission >
              <![CDATA[Permission for findByPK method]]>


              <ejb-name>ControlLogix</ejb-name>
              <method-name>findByPrimaryKey</method-name>

              </method-permission>

              <!-- transactions -->
              <!--
              To specify additional container-transaction elements, add a file in the merge
              directory called ejb-container-transaction.ent that contains them.
              -->
              <container-transaction >

              <ejb-name>ControlLogix</ejb-name>
              <method-intf>Local</method-intf>
              <method-name>process</method-name>
              <method-params>
              </method-params>

              <trans-attribute>Required</trans-attribute>
              </container-transaction>
              <container-transaction >

              <ejb-name>ControlLogix</ejb-name>
              <method-intf>Remote</method-intf>
              <method-name>process</method-name>
              <method-params>
              </method-params>

              <trans-attribute>Required</trans-attribute>
              </container-transaction>

              <!-- finder transactions -->

              <!--
              To specify an exclude-list element, add a file in the merge directory
              called ejb-exclude-list.xml that contains it.
              -->
              </assembly-descriptor>

              </ejb-jar>

              • 4. Re: EJB QL Parsing problem
                dab

                The problem still persists. I've tried to set the sql-type to BLOB and the jdbc-type to BLOB but that does not seem to make a difference.

                Is there some kind of a problem with BLOB oriented data types and ejbql comparisons?

                • 5. Re: EJB QL Parsing problem
                  raist_majere

                  What's the type for location? Is it a BLOB or something like this? Can you tell us the Java type of this CMP field? If, as you said (or I understood), "location" is a BLOB or similar, then you're right when supposing that this kind of CMP fields "have a problem" with EJBQL, 'cause as you caould read in the EJB specification, the equality comparisons are not scopped to that kind of types... Well, I'm not sure about what I'm going to say, but I think that in a "normal" SQL select you cannot neither compare BLOB columns (that is, databases don't support it).
                  Hope this helps.

                  • 6. Re: EJB QL Parsing problem
                    dab

                    Ok,

                    Quick comment. The locatin ield is a BLOB type. It works flawlessly in BEA's Weblogic. I'm actually trying to port this code to JBoss & Websphere. Both have their issues!

                    Many thanks for the reply. Any suggestions are welcome. I'll check to see if the BLOB issue is the cause.

                    Maybe BEA goes over and above the spec?