Are there any known bugs involving findByPrimaryKey?
I have an extremely simple entity bean that uses a String for its primary
key. I can create an entity with no problem, but finding with the primary
key used to create it, fails with an
"java.lang.reflect.UndeclaredThrowableException". (I'm trying to catch
java.lang.Exception). There's no error on the server, but a lot of what
appears to be transaction activity. (I'm using the latest from CVS
--dated 10/3). I know the entity was created since, trying to create
another with the same key, throws a DuplicateKeyException.
Thanks,
Jason
I'll post the code below if that's helpful:
--------------------------------------------------------------------------------------------
Client:
package assetmgr;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
public class TestClient {
public static void main(String[] args) {
try {
InitialContext ic = new InitialContext();
Object ref = ic.lookup("User");
UserHome home =
(UserHome)PortableRemoteObject.narrow(ref, UserHome.class);
User user = home.findByPrimaryKey("rz95127");
} catch (Exception e) {
System.out.println(e);
}
}
}
--------------------------------------------------------------------------------------------
Remote interface:
package assetmgr;
import javax.ejb.EJBObject;
public interface User extends EJBObject {
}
--------------------------------------------------------------------------------------------
Home interface:
package assetmgr;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface UserHome extends EJBHome {
public User create(String userid) throws RemoteException,
CreateException;
public User findByPrimaryKey(String key) throws RemoteException,
FinderException;
}
--------------------------------------------------------------------------------------------
EJB Class:
package assetmgr;
import javax.ejb.*;
public class UserEJB implements EntityBean {
private EntityContext ctx;
public String userId;
public void ejbActivate() { }
public void ejbPassivate() { }
public void ejbLoad() { }
public void ejbStore() { }
public void ejbRemove() { }
public void setEntityContext(EntityContext ctx) {
this.ctx = ctx;
}
public void unsetEntityContext() {
this.ctx = null;
}
public String ejbCreate(String userid) {
this.userId = userid;
return null; //null for CMP
}
public void ejbPostCreate(String userid) { }
}
--------------------------------------------------------------------------------------------
ejb-jar.xml:
<ejb-jar>
<description>Asset Management System</description>
<display-name>AssetManager</display-name>
<enterprise-beans>
<entity>
<description>UserEntity</description>
<display-name>User</display-name>
<ejb-name>User</ejb-name>
<home>assetmgr.UserHome</home>
<remote>assetmgr.User</remote>
<ejb-class>assetmgr.UserEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-field>
<description>Logon ID of the
user</description>
<field-name>userId</field-name>
</cmp-field>
<primkey-field>userId</primkey-field>
</entity>
</enterprise-beans>
</ejb-jar>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]