2 Replies Latest reply on Feb 8, 2005 3:51 AM by Jarva Jarva

    Error compiling EJB-QL statement

    Jarva Jarva Newbie

      Hi!!

      I'm trying to deploy an Entity EJB with Jboss 4.0.1, who has previos been created by Xdoclet 1.2.2. My Entity Bean is like that:

      /**
       * @ejb.bean name = "BonusBean"
       * type = "CMP"
       * cmp-version = "2.x"
       * display-name = "BonusBean"
       * description = "BonusBean EJB"
       * view-type = "both"
       * jndi-name = "ejb/BonusBeanHome"
       * local-jndi-name = "ejb/BonusBeanLocalHome"
       * primkey-field = "identificador"
       * @ejb.persistence table-name = "TMP_EJEMPLO"
       * @jboss.persistence table-name = "TMP_EJEMPLO"
       * @ejb.finder
       * query="SELECT OBJECT(a) FROM TMP_EJEMPLO AS a"
       * signature="java.util.Collection findAll()"
       *
       * @ejb.resource-ref res-ref-name = "/qnecta/bbdd/jdbc/OracleDS"
       * res-type = "javax.sql.DataSource"
       * res-auth = "Container"
       *
       * @jboss.resource-ref res-ref-name = "/qnecta/bbdd/jdbc/OracleDS"
       * jndi-name = "/qnecta/bbdd/jdbc/OracleDS"
       */
      public abstract class BonusBean implements EntityBean {
      
       protected EntityContext entityContext;
      
       /**
       * @ejb.interface-method view-type = "both"
       * @ejb.persistence column-name = "descripcion"
       * @ejb.pk-field
       *
       * @return
       */
       public abstract String getDescripcion();
      
       /**
       * @ejb.interface-method view-type = "both"
       *
       * @param name
       */
       public abstract void setDescripcion(String descripcion);
      
       /**
       * @ejb.interface-method view-type = "both"
       * @ejb.persistence column-name = "identificador"
       * @ejb.pk-field
       *
       * @return
       */
       public abstract String getIdentificador();
      
       /**
       * @ejb.interface-method view-type = "both"
       *
       * @param name
       */
       public abstract void setIdentificador(String identificador);
      
       /**
       * @ejb.interface-method view-type = "both"
       * @ejb.persistence column-name = "nombre"
       *
       * @return
       */
       public abstract String getNombre();
      
       /**
       * @ejb.interface-method view-type = "both"
       *
       * @param name
       */
       public abstract void setNombre(String nombre);
      
       /**
       *
       * TODO (Explicacion del Metodo)
       * @param id
       * @param nombre
       * @param descripcion
       * @return
       * @throws CreateException
       *
       * @ejb.create-method view-type = "local"
       */
       public String ejbCreate(String id, String nombre, String descripcion)
       throws CreateException
       {
       try {
       BonusBeanLocalHome localHome=BonusBeanUtil.getLocalHome();
       BonusBeanLocal local=localHome.create(id,nombre,descripcion);
       } catch (NamingException e) {
       e.printStackTrace();
       }
       setIdentificador(id);
       setNombre(nombre);
       setDescripcion(descripcion);
       return null;
      
       }
      
       public void ejbPostCreate(String id, String nombre, String descripcion)
       {
       }
      
       public void ejbActivate() {
       //Called by container before Bean
       //swapped into memory
       }
      
       public void ejbPassivate() {
       //Called by container before
       //Bean swapped into storage
       }
      
       public void ejbRemove() throws RemoteException {
       //Called by container before
       //data removed from database
       }
      
       public void ejbLoad() {
       //Called by container to
       //refresh entity Bean's state
       }
      
       public void ejbStore() {
       //Called by container to save
       //Bean's state to database
       }
      
       public void setEntityContext(EntityContext ctx){
       this.entityContext = ctx;
       }
      
       public void unsetEntityContext(){
       this.entityContext = null;
       }
       }


      And "jboss.xml":
      <jboss>
      
       <enterprise-beans>
      
       <!--
       To add beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called jboss-beans.xml that contains
       the <session></session>, <entity></entity> and <message-driven></message-driven>
       markup for those beans.
       -->
      
       <entity>
       <ejb-name>BonusBean</ejb-name>
       <jndi-name>ejb/BonusBeanHome</jndi-name>
       <local-jndi-name>ejb/BonusBeanLocalHome</local-jndi-name>
       <resource-ref>
       <res-ref-name>/qnecta/bbdd/jdbc/OracleDS</res-ref-name>
       <jndi-name>/qnecta/bbdd/jdbc/OracleDS</jndi-name>
       </resource-ref>
      
       <method-attributes>
       </method-attributes>
      
       </entity>
      
       </enterprise-beans>
      
       <resource-managers>
       </resource-managers>
      
      </jboss>


      And "ejb-jar.xml" is like that:
      <?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 >
      
       <description><![CDATA[No Description.]]></description>
       <display-name>Generated by XDoclet</display-name>
      
       <enterprise-beans>
       <!-- Entity Beans -->
       <entity >
       <description><![CDATA[BonusBean EJB]]></description>
       <display-name>BonusBean</display-name>
      
       <ejb-name>BonusBean</ejb-name>
      
       <home>entity.gen.BonusBeanHome</home>
       <remote>entity.gen.BonusBean</remote>
       <local-home>entity.gen.BonusBeanLocalHome</local-home>
       <local>entity.gen.BonusBeanLocal</local>
      
       <ejb-class>entity.ejb.BonusBeanCMP</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.String</prim-key-class>
       <reentrant>False</reentrant>
       <cmp-version>2.x</cmp-version>
       <abstract-schema-name>TMP_EJEMPLO</abstract-schema-name>
       <cmp-field >
       <description><![CDATA[]]></description>
       <field-name>descripcion</field-name>
       </cmp-field>
       <cmp-field >
       <description><![CDATA[]]></description>
       <field-name>identificador</field-name>
       </cmp-field>
       <cmp-field >
       <description><![CDATA[]]></description>
       <field-name>nombre</field-name>
       </cmp-field>
       <primkey-field>identificador</primkey-field>
      
       <resource-ref >
       <res-ref-name>/qnecta/bbdd/jdbc/OracleDS_QTFINF</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
       <query>
       <query-method>
       <method-name>findAll</method-name>
       <method-params>
       </method-params>
       </query-method>
       <ejb-ql><![CDATA[SELECT OBJECT(a) FROM tmp_ejemplo AS a]]></ejb-ql>
       </query>
       <!-- Write a file named ejb-finders-BonusBean.xml if you want to define extra finders. -->
       </entity>
       </assembly-descriptor>
      
      </ejb-jar>
      


      When i try to deploy it, i've this exception:
      Starting failed jboss.j2ee:jndiName=BonusBean,service=EJB
      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT OBJECT(a) FROM tmp_ejemplo AS a'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "tmp_ejemplo" at line 1, column 23.
      Was expecting one of:
       "IN" ...
       <ABSTRACT_SCHEMA> ...
       )


      I'm wrong on my EJB QL statement?? I've try with several statements like this, very simple, but it does'nt works!!!

      Thanks!