1 Reply Latest reply on Apr 9, 2003 8:46 PM by Keith Pemberton

    Query method not found...

    Keith Pemberton Newbie

      All,

      I have run into a problem with JBoss3.2RC4. I have a simple entity bean that I put in the RemoteHome interface class a method called findByUsername. This is a CMP 2.0 entity bean, so it is an abstract method. I have included ejb-jar.xml and jbosscmp-jdbc.xml files and will post their contents below. When trying to deploy this ejb, JBoss says: "Query Method not found: findByUsername" followed by the stack trace. I have read posts and books until I am blue in the face and I still cannot determine what the problem is. Is anyone else experiencing this type of problem? I am using 3.2RC4 because I want to use auto_increment for a MySQL database. Here are the ejb-jar.xml and jbosscmp-jdbc.xml file respectivly. Thanks in advance for any help!

      ejb-jar.xml
      ------------------------------------------------------------------------------
      <?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>
      <enterprise-beans>

      <ejb-name>UserEJB</ejb-name>
      com.gatep5.ejb.UserEJB.UserHome
      com.gatep5.ejb.UserEJB.User
      <ejb-class>com.gatep5.ejb.UserEJB.UserBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Object</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Users</abstract-schema-name>
      <cmp-field><field-name>username</field-name></cmp-field>
      <cmp-field><field-name>password</field-name></cmp-field>
      <cmp-field><field-name>email</field-name></cmp-field>
      <cmp-field><field-name>colorScheme</field-name></cmp-field>
      <cmp-field><field-name>signature</field-name></cmp-field>
      <resource-ref>
      <res-ref-name>jdbc/MySqlDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      <query-method>
      <method-name>findByUsername</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      SELECT OBJECT(u) FROM Users AS u WHERE u.username = ?1
      </ejb-ql>



      </enterprise-beans>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>UserEJB</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>
      ---------------------------------------------------------------------------

      jbosscmp-jdbc.xml
      ---------------------------------------------------------------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC
      "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN"
      "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">

      <jbosscmp-jdbc>

      java:/MySqlDS
      <datasource-mapping>mySQL</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <pk-constraint>true</pk-constraint>
      <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <field-name>id</field-name>
      <column-name>id</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INT(10)</sql-type>
      <auto-increment/>
      </unknown-pk>
      <entity-command name="mysql-get-generated-keys"/>


      <enterprise-beans>

      <ejb-name>UserEJB</ejb-name>
      <table-name>users</table-name>
      <cmp-field>
      <field-name>username</field-name>
      <column-name>username</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>password</field-name>
      <column-name>password</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>email</field-name>
      <column-name>email</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>colorScheme</field-name>
      <column-name>colorScheme</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>signature</field-name>
      <column-name>signature</column-name>
      </cmp-field>

      </enterprise-beans>

      </jbosscmp-jdbc>
      ---------------------------------------------------------------------------------

        • 1. Re: Query method not found...
          Keith Pemberton Newbie

          Well, I have determined one thing at least. The method is found only if the the EJB jar file is outside of an ear file. So, I have put it directly under the the deploy directory. Then, if I place my war file under the deploy directory as well then everything is just fine. It is only when I try to combine the two into an ear file that it either says that the query cannot be found or it just won't find the EJB in the first place. The application.xml file is correct, though. Anyway, I am wondering if this is a bug. Can anyone else confirm this happening with 3.2RC4? Will there be another RC before the final 3.2 version? Thanks in advance!