Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity EJB - FinderException  RSS feed

 
Yoo-Jin Lee
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I'm new to ejbs and cannot understand why my client program cannot find the method findAll.
I get the following exception:
javax.ejb.FinderException: Logs entity has no finder named: findAll
Relevant info:
Development: JBuilder 6, Borland Enterprise Server 5.0
Client.java
<code>
Context ctx = new InitialContext();
Object ref = ctx.lookup("LogsRemote");
LogsRemoteHome logsHome = (LogsRemoteHome) PortableRemoteObject.narrow(ref, LogsRemoteHome.class);
</code>
ejb-jar.xml
<code>
<?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>
<entity>
<display-name>Logs</display-name>
<ejb-name>Logs</ejb-name>
<home>ejbsample.LogsRemoteHome</home>
<remote>ejbsample.LogsRemote</remote>
<local-home>ejbsample.LogsHome</local-home>
<local>ejbsample.Logs</local>
<ejb-class>ejbsample.LogsBean</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>Logs</abstract-schema-name>
<cmp-field>
<field-name>itemData</field-name>
</cmp-field>
<cmp-field>
<field-name>itemDate</field-name>
</cmp-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params />
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql/>
</query>
<query>
<query-method>
<method-name>findByItemDate</method-name>
<method-params />
</query-method>
<result-type-mapping>Local</result-type-mapping>
<ejb-ql />
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Logs</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
</code>
LogsHome.java
<code>
....
public interface LogsHome extends javax.ejb.EJBLocalHome {
public Logs create() throws CreateException;
public Logs create(java.lang.String itemData) throws CreateException;
public java.util.Collection findAll() throws FinderException, RemoteException;
public Logs findByItemDate() throws FinderException;
public Logs findByPrimaryKey(java.lang.String itemData) throws FinderException;
}
</code>
LogsRemoteHome.java
<code>
....
public interface LogsRemoteHome extends javax.ejb.EJBHome {
public LogsRemote create() throws CreateException, RemoteException;
public LogsRemote create(java.lang.String itemData) throws CreateException, RemoteException;
public java.util.Collection findAll() throws FinderException, RemoteException;
public LogsRemote findByItemDate() throws FinderException, RemoteException;
public LogsRemote findByPrimaryKey(java.lang.String itemData) throws FinderException, RemoteException;
}
</code>
Logs.java
<code>
public interface Logs extends javax.ejb.EJBLocalObject {
public java.lang.String getItemData();
public void setItemDate(byte[] itemDate);
public byte[] getItemDate();
public void setProduct(java.lang.String product);
public java.lang.String getProduct();
public void setItemid(java.lang.Float itemid);
public java.lang.Float getItemid();
public void setItemType(java.lang.String itemType);
public java.lang.String getItemType();
public void setItemSession(java.lang.String itemSession);
public java.lang.String getItemSession();
}
</code>
LogsBean.java
<code>
...
public abstract class LogsBean implements EntityBean {
EntityContext entityContext;
public java.lang.String ejbCreate() throws CreateException {
return null;
}
public java.lang.String ejbCreate(java.lang.String itemData) throws CreateException {
setItemData(itemData);
return null;
}
public void ejbPostCreate() throws CreateException {
}
public void ejbPostCreate(java.lang.String itemData) throws CreateException {
}
public void ejbRemove() throws RemoveException {
}
public abstract void setItemData(java.lang.String itemData);
public abstract void setItemDate(byte[] itemDate);
public abstract void setProduct(java.lang.String product);
public abstract void setItemid(java.lang.Float itemid);
public abstract void setItemType(java.lang.String itemType);
public abstract void setItemSession(java.lang.String itemSession);
public abstract java.lang.String getItemSession();
public abstract java.lang.String getItemType();
public abstract java.lang.Float getItemid();
public abstract java.lang.String getProduct();
public abstract byte[] getItemDate();
public abstract java.lang.String getItemData();
public void ejbLoad() {
}
public void ejbStore() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void unsetEntityContext() {
this.entityContext = null;
}
public void setEntityContext(EntityContext entityContext) {
this.entityContext = entityContext;
}
}
</code>
Any insights would be greatly appreciated!
Yoo-Jin.
 
kevin alexander
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It looks like you're trying to access a local entity bean from a normal command-line client. I too tried this when deploying my first local entity bean and got a similar result.
I had to write and deploy another entity bean (not a local bean -- but i suppose a session bean would work also) and to find and use the local entity bean.. So you have your local entity bean, called by a client bean (not local entitiy), which is in turn called by your client command line program.
It's kind of a "scope" issue. Since local entity beans run within the same JVM, the client application you wrote is "out of the scope" and therefore isn't finding the local bean.
Hope that helps.. Maybe someone could offer a more technical expalation if this doesn't suffice..
Also, I'm not sure these local beans throw RemoteExceptions -- you might want to check that also.
-kevin
[ January 15, 2002: Message edited by: kevin alexander ]
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you deploy your bean successfully ?
1. You have to put some EJB-QL for your finder methods - like
<ejb-ql>select object(o) from Logs o</ejb-ql>.
2. You can't throw RemoteException from local home methods.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!