2 Replies Latest reply on Mar 5, 2003 2:15 PM by Charles

    JBossCmp and Custom Finders

    Charles Newbie

      (This was sent as a reply to Jboss 3.0 Alpha and Custom Finders but doesn't seem to want to post, so I'm submitting it as a new topic)

      I'm getting the following deployment error from JBoss for my ejbql. Have looked at examples as well as spec, and don't really see what JBoss (3.0.4) doesn't like about it.

      Any suggestions will be greatly appreciated!

      Error from JBoss:

      14:08:25,265 INFO [MainDeployer] Starting deployment of package: file:/C:/Frame
      14:08:25,375 INFO [EjbModule] Creating
      14:08:25,390 INFO [EjbModule] Deploying TWUserRole
      14:08:25,406 INFO [EjbModule] Deploying ManageTWUserRole
      14:08:25,406 INFO [EjbModule] Deploying test/SequenceGenerator
      14:08:25,437 INFO [EjbModule] Created
      14:08:25,437 INFO [EjbModule] Starting
      14:08:30,859 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/test/TWUserRoleHome,service=EJB
      org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "TWUSERROLE" at line 1, column 23.
      Was expecting one of:
      "IN" ...
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:44)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCQueryManager.start(JDBCQueryManager.java:218)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDBCStoreManager.java:463)


      Bean code and XDoclet header:

      * This is a user role bean. It is an example of how to use the XDoclet tags.
      * @ejb:bean
      * name="test/TWUserRole"
      * type="CMP"
      * jndi-name="ejb/test/TWUserRoleHome"
      * @ejb:data-object extends="test.interfaces.AbstractData"
      * setdata="false"
      * @ejb:finder signature="java.util.Collection findUserRolesByUserId(int userId)" unchecked="true" query="SELECT OBJECT(u) FROM TWUSERROLE AS u WHERE u.USER_USERID = ?1"
      * @jboss:table-name "TWUSERROLE"
      * @jboss:create-table "${jboss.create.table}"
      * @jboss:remove-table "${jboss.remove.table}"
      * @jboss:tuned-updates "${jboss.tuned.updates}"
      * @jboss:read-only "${jboss.read.only}"
      * @version $Revision: 1.0 $
      * @author $Author: Charles $

      public abstract java.util.Collection findUserRolesByUserId( int userId ) throws FinderException;


      Output after running ant:


      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Name.]]>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's id.]]>

      <ejb-ql><![CDATA[SELECT OBJECT(u) FROM TWUSERROLE AS u WHERE u.USER_USERID = ?1]]></ejb-ql>

        • 1. Re: JBossCmp and Custom Finders
          gernot Newbie

          In the query part of or @ejb:finder you need the abstract-schema-name not your table name. The abstract-schema-name (see your ejb-jar.xml file) is set by xdoclet. It uses the name attribute of your @ejb:bean tag. So the correct query part would be:
          SELECT OBJECT(u) FROM test/TWUserRole AS u WHERE u.USER_USERID = ?1
          I'm not sure if you can use a "/" their but give it a try.
          But I think it would be better if you also change the name attribute to a value without "/" :-)


          • 2. Re: JBossCmp and Custom Finders
            Charles Newbie

            Thanks - you are correct. By using the bean name and the field names found in <field-name> in the jbosscmp-jdbc.xml I resolved the problem.