code: private Serializable readExternalPKey(ObjectInput in, byte[] j2eeNameBytes)
                      throws java.io.IOException, ClassNotFoundException {
  
          int pkeyLength = in.readInt();
          byte[] pkeyBytes = new byte[pkeyLength];
  
          //d164415 start
          int bytesRead = 0;
          for (int offset = 0; offset < pkeyLength; offset += bytesRead)
          {
              bytesRead = in.read(pkeyBytes, offset, pkeyLength - offset);
              if (bytesRead == -1)
              {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                      Tr.debug(tc, "readExternalKey encountered end of stream");
                  throw new IOException("end of input stream while reading primary key");
              }
          }
          //d164415 end
  
          //
          // What we are trying to do here is to get the j2eename of the
          // bean in question. The reason we want to do this, we have get
          // the ClassLoader of the bean before we attempt to deserialize
          // the primary key. The container ClassLoader is no longer aware
          // of the bean classes.
          // This path may be traversed on a call to keyToObject. In that
          // situation, the thread's context ClassLoader is of no use. So we
          // have to use some static methods to access the container and get
          // the specific ClassLoader for the bean
          //
          final EJSContainer container = EJSContainer.getDefaultContainer();
          J2EEName j2eename = container.getJ2EENameFactory().create(j2eeNameBytes);
          ByteArrayInputStream bais = new ByteArrayInputStream(pkeyBytes);
  
          //
          // Use a ObjectInputStream, it can then use the bean's ClassLoader
          // to resolve the primary key class.
          //
          ClassLoader loader = EJSContainer.getClassLoader(j2eename);
          ObjectInputStream pkeyStream =
                          container.getEJBRuntime().createObjectInputStream(bais, loader); // RTC71814
          Serializable key = (Serializable) pkeyStream.readObject();
          return key;
      }
docs: Private helper method for readExternal - reads the Serialized
  primary key.
  
  @author Adrian Colyer
  @return java.io.Serializable
  @param in java.io.ObjectInput
  @exception java.io.IOException The exception description.