1 Reply Latest reply on Sep 4, 2002 11:58 AM by Dain Sundstrom

    Remote Exception when using Composite Primary Key

    Damian Sutton Newbie

      Hi All,

      I have noticed that most people with Composite Primary Key Problems have trouble getting them to work. I don't seem to have a problem creating, doploying or using Composite Primary Keys on JBoss 3.0.1 / Tomcat 4.0.4 .

      But I have found that when using remote methods on the bean that has a Composite Primary Key, a Remote Exception is thrown.

      I can use the home.findByPrimaryKey(myKey) method successfully, I print the bean that is returned (I works). But if I call any get or set methods it brakes.

      Here some of my code that might help.

      (in the ejb-jar.xml)

      Models the TxCarcass Table

      (primary key class)
      public class TxCarcassKey implements java.io.Serializable {
      public String site;
      public String deviceAddr;
      public String devicePort;
      public Date txDate;
      public Integer txSeq;

      /** Creates a new instance of TxCarcassKey */
      public TxCarcassKey() { }

      public boolean equals(Object obj) {
      if(obj == null) {
      return false;
      if(obj instanceof TxCarcassKey) {
      if(((TxCarcassKey)obj).hashCode() ==
      this.hashCode()) {
      return true;
      return false;

      public int hashCode() {
      return this.toString().hashCode();

      public String toString() {
      return site + "|" + deviceAddr + "|" + devicePort + "|" + txDate.toString() + "|" + txSeq.toString();

      (implementation bean create method)
      public TxCarcassKey ejbCreate(String site, String deviceAddr, String devicePort, Date txDate, Integer txSeq) {
      this.site = site;
      this.deviceAddr = deviceAddr;
      this.devicePort = devicePort;
      this.txDate = txDate;
      this.txSeq = txSeq;
      return null;

      (home class)
      public interface TxCarcassHome extends javax.ejb.EJBHome {
      public TxCarcass create(String site, String
      deviceAddr, String devicePort, Date txDate, Integer txSeq) throws RemoteException, CreateException;

      public TxCarcass findByPrimaryKey(TxCarcassKey key)throws RemoteException, FinderException;

      public java.util.Collection findAll() throws RemoteException, FinderException;

      (test client)
      public static void main(String[] args) {
      try {
      SimpleDateFormat sf = new SimpleDateFormat ("dd/MM/yyyy");
      InitialContext namingContext = new InitialContext();
      TxCarcassHome home = (TxCarcassHome) PortableRemoteObject.narrow(namingContext.lookup ("TxCarcassBean"), TxCarcassHome.class);
      TxCarcassKey key = new TxCarcassKey();
      key.site = "TEST SITE 2";
      key.deviceAddr = "A";
      key.devicePort = "1";
      key.txDate = sf.parse("29/08/2002");
      key.txSeq = new Integer(0);
      TxCarcass bean = home.findByPrimaryKey(key);
      } catch (Exception z) {

      (output from test)

      TxCarcassBean:TEST SITE 2|A|1|Thu Aug 29 00:00:00 EST 2002|0
      java.rmi.ServerException: RemoteException occurred in server thread; nested exce
      ption is:
      java.rmi.ServerException: Load failed; nested exception is:
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:

      ....and lots more

      Sorry about how long this has been, but please can someone help me out.