1 Reply Latest reply on Jan 19, 2004 10:17 PM by ebaskoro

    Error compiling EJB-QL statement

    Chris Malan Novice

      Dear All,

      This is not as simple as the subject heading seems to indicate.

      The background of the problem is as follows:

      I have two CMP beans, RoleCMPEntityBean and PrincipalCMPEntityBean.
      There is a n:m relationship between them - one principal can belong to many roles and one role can have many principals.

      The relationship table (user_role_rel_tbl) is created by the container - JBoss.

      When I deploy the jar file this is what I get from the JBoss feedback (just some of the error parts copied here):

      As soon as it is the turn for roles_tbl to be created I get:

      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement ''; - nested throwable:
      (org.jboss.ejb.plugins.cmp.ejbql.ParseException: FROM not found)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46) etc, etc ad nauseam

      Then, much later:

      Caused by: org.jboss.ejb.plugins.cmp.ejbql.ParseException: FROM not found
      at org.jboss.ejb.plugins.cmp.ejbql.EJBQLParser.parse(EJBQLParser.java:38)

      And again a bit later:

      12:10:34,135 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=RolesCMPEntityLocal,service=EJB
      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement ''; - nested throwable:
      (org.jboss.ejb.plugins.cmp.ejbql.ParseException: FROM not found)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)

      Skipping some of the same we find right at the end:

      Depends On Me: , ObjectName: jboss.j2ee:jndiName=RolesCMPEntityLocal,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement ''; - nested throwable:
      (org.jboss.ejb.plugins.cmp.ejbql.ParseException: FROM not found)]

      The roles_tbl and subsequent tables are not created.

      There is only one finder method with EJB QL, findAll(). Here are its XDoclet tags:

      * @ejb.finder
      * query="SELECT OBJECT(a) FROM rolesSchema as a"
      * signature="java.util.Collection findAll()"
      * result-type-mapping="Local"
      * view-type="local"
      * description="Finds all roles"
      * transaction-type="Supports"
      * unchecked="true"
      *
      * @jboss.query
      * query="SELECT OBJECT(a) FROM rolesSchema as a"
      * signature="java.util.Collection findAll()"

      The generated query in ejb-jar.xml looks exactly like that of the table which is created and therfore obviously is correct.

      Of course, the finder method appears in the localHome interface and the local interface is mentioned in the error messages. The only methods apart from the setRoleName and getRoleName are the getters and setters for the CMR attributes, user names in this case. This is what the XDoclet tags look like in the RoleCMPEntityBean:

      /**
      * @return Returns a java.util.Collection of users
      * @ejb.relation
      * name="principal-role-relationship"
      * role-name="role-to-principal"
      * cascade-delete="no"
      *
      * @ejb.transaction
      * type="Required"
      * @ejb.permission
      * unchecked="true"
      * @ejb.interface-method
      * view-type="local"
      *
      * @jboss.relation-mapping
      * style="relation-table"
      *
      * @jboss.relation-table
      * table-name="user_role_rel_tbl"
      * create-table="true"
      * remove-table="false"
      *
      * @jboss.relation
      * fk-constraint="false"
      * related-pk-field="username"
      * fk-column="users"
      **/
      public abstract java.util.Collection getUsers();


      /**
      * Set Users.
      *
      * @param newUsers The new Value for Users.
      *
      * @ejb.interface-method
      * @ejb.transaction
      * type="Required"
      * @ejb.permission
      * role-name="manager"
      **/
      public abstract void setUsers(java.util.Collection newUsers);

      I have another application using this same user-role set-up. Things are exactly the same, except that everything works for the other application.

      This is what the abstract methods in the local interface look like:

      /**
      * Returns a java.util.Collection of users
      * @return the users
      */
      public java.util.Collection getUsers( ) ;

      /**
      * Set Users.
      * @param newUsers The new Value for Users.
      */
      public void setUsers( java.util.Collection newUsers ) ;

      Obviously, there is nothing generated for this in the ejb-jar.xml file. These are just getter and setter methods, except that they return a Collection.

      This is a sticky problem. I have pored over it and can't get the solution. In fact, everything seems fine to me. Is there anybody who can help? I am really stuck.

      Thanks,

      Chris

        • 1. Re: Error compiling EJB-QL statement
          ebaskoro Newbie

          G'Day,

          What you have posted there only mentions the RoleCMPEntityBean relationship methods. How about PrincipalCMPEntityBean? You should have something like:

          /**
          * @ejb.relation name="principal-role-relationship"
          * role-name="principal-to-user"
          *
          * @jboss.relation related-pk-field="principal"
          * fk-column="principal"
          *
          * @ejb.interface-method
          */
          public abstract Collection getPrincipals();

          /**
          * @ejb.interface-method
          */
          public abstract void setPrincipals( Collection newPrincipals );