You may have discovered a bug.  As far as I can tell, jboss incorrectly filters out 
custom finder methods that don't begin with "ejbFindBy". Your method is filtered out. 
An attempt is made to autogenerate a finder, which results in the indicated message.

Change the name of your method to ejbFindByIdAndName and try again. If that works, let 
me know and I'll submit a patch.

--
Fred Loney
Spirited Software, Inc.
[EMAIL PROTECTED]

nathan frund wrote:

> Howdy,
>
> I'm new to both EJB and JBoss and boy, do I have a
> problem.  I've been over the documentation on the
> JBoss web site for days and through the mailing list
> archive from top to bottom but didn't find anyone else
> having this specific problem.
>
> I can't get certain custom finders to work.
>
> This is the error message I get in the JBoss log when
> starting the server:
>
>         [Container factory] Finder:idandname
>         [JAWS] Could not create the finder findByIdAndName,
> because no matching CMP field was found.
>
> ================================================
>
> Here is the snippet from the included jaws.xml:
>
>         <entity>
>                 <ejb-name>ArticleBean</ejb-name>
>                 <pk-constraint>true</pk-constraint>
>                 <cmp-field>
>                         <field-name>id</field-name>
>                         <column-name>ID</column-name>
>                 </cmp-field>
>                 <cmp-field>
>                 <field-name>name</field-name>
>                 <column-name>NAME</column-name>
>                 </cmp-field>
>                 <finder>
>                         <name>findById</name>
>                         <query>ID = {0}</query>
>                         <order>ID DESC</order>
>                 </finder>
>                 <finder>
>                         <name>findByIdAndName</name>
>                         <query><![CDATA[id ={0} AND
> name={1}]]></query>
>                         <order>id DESC</order>
>                 </finder>
>         </entity>
>
> ===================================================
>
> Here is the Home interface of the EJB:
>
> package com.nathanfrund.xwl;
>
> import java.rmi.RemoteException;
> import javax.ejb.*;
> import java.util.Collection;
>
> /**
> This interface defines the home interface for the
> 'Article' EJB.
> */
> public interface ArticleHome extends EJBHome
> {
>     /**
>     Create a new XWL instance.
>     */
>     public Article create(Integer id) throws
> RemoteException, CreateException;
>
>     /**
>     Find the Article with the specified ID.  This
> method is not implemented by
>     the Bean, but by the container.
>     */
>     public Article findByPrimaryKey(Integer id) throws
> RemoteException, FinderException;
>
>     /**
>     Finds the Article whose 'name' attribute matches
> that specified.  This
>     method is implemented byt he container
>     */
>     public Collection findByName(String name) throws
> RemoteException, FinderException;
>
>     /**
>     Get all Article instances.  This method is
> implemented by the container
>     */
>     public Collection findAll() throws
> RemoteException, FinderException;
>
>     public Collection findByIdAndName(Integer id,
> String name) throws RemoteException, FinderException;
> }
>
> =====================================================
>
> The overridden "findById" works perfectly and of
> course the "findByIdAndName" returns an empty
> Collection when called by a client.  Any help would be
> *GREATLY* appreciated.
>
> For completeness sake here's the CMP bean:
>
> =======================================================
>
> package com.nathanfrund.xwl;
>
> import java.rmi.RemoteException;
> import javax.ejb.*;
> import org.jboss.util.AutoNumberFactory;
> /**
> This class contains the implementation for the methods
> specified in the home
> and remote interfaces for the 'XWL' EJB.
> */
> public class ArticleBean implements EntityBean
> {
>     transient private EntityContext ctx;
>
>     static java.util.Date now = new java.util.Date();
>
>     public Integer id;
>     public boolean reviewed;
>     public java.sql.Date date;
>     public java.sql.Time time;
>     public String topic;
>     public String title;
>     public String department;
>     public String summary;
>     public String body;
>     public String name;
>     public String email;
>
>     /**
>         Create an instance of a CD.  Note that this
> method returns null because
>         the real creation is managed by the EJB
> container.
>     */
>     public Integer ejbCreate (Integer _id)
>     {
>         id =
> AutoNumberFactory.getNextInteger("ArticleBean");
>         date = new java.sql.Date(now.getTime());
>         time = new java.sql.Time(now.getTime());
>         return null;
>     }
>
>     /**
>         Called when the object has been instantiated;
> does nothing here.
>     */
>     public void ejbPostCreate(Integer id){}
>
>     public Integer getId(){ return id; }
>
>     public boolean getReviewed(){ return reviewed; }
>     public void setReviewed(boolean _reviewed){
> reviewed = _reviewed; }
>
>     public java.sql.Date getDate(){ return date; }
>
>     public java.sql.Time getTime(){ return time; }
>
>     public String getTopic() { return topic; }
>     public void setTopic(String _topic){  topic =
> _topic; }
>
>     public String getTitle(){ return title; }
>     public void setTitle(String _title){ title =
> _title; }
>
>     public String getDepartment(){ return department;
> }
>     public void setDepartment(String _department){
> department = _department; }
>
>     public String getSummary(){ return summary; }
>     public void setSummary(String _summary){ summary =
> _summary; }
>
>     public String getBody(){ return body; }
>     public void setBody(String _body){ body = _body; }
>
>     public String getName(){ return name; }
>     public void setName(String _name){ name = _name; }
>
>     public String getEmail(){ return email; }
>     public void setEmail(String _email){ email =
> _email; }
>
>     public void setEntityContext(EntityContext ctx){
> this.ctx = ctx; }
>
>     public void unsetEntityContext() { ctx = null; }
>
>     public void ejbActivate() {}
>     public void ejbPassivate() {}
>     public void ejbLoad() {}
>     public void ejbStore() {}
>     public void ejbRemove() {}
> }
>
>


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to