entry.put( JCLASSNAMES_ATTR, classes[ii].getName() );
bytesOut = new ByteArrayOutputStream(); out = new ObjectOutputStream( bytesOut ); out.writeObject( obj ); return bytesOut.toByteArray(); } catch ( Exception e ) { NamingException ne = new NamingException( "Serialization of '" + obj + "' failed:\n" + e.getMessage() ); ne.setRootCause( e ); throw ne; } finally { try { out.close(); } catch ( IOException e ) { throw new NamingException( "object serialization stream close() failure" ); }
    static void serialize( Attributes entry, Object obj ) throws NamingException    {        /* Let's add the object classes first:         * objectClass: top         * objectClass: javaObject         * objectClass: javaContainer         * objectClass: javaSerializedObject         */        entry.put( OBJECTCLASS_ATTR, TOP_ATTR );        entry.put( OBJECTCLASS_ATTR, JOBJECT_ATTR );        entry.put( OBJECTCLASS_ATTR, JCONTAINER_ATTR );        entry.put( OBJECTCLASS_ATTR, JSERIALIZEDOBJ_ATTR );        // Add the javaClassName and javaSerializedData attributes        entry.put( JCLASSNAME_ATTR, obj.getClass().getName() );        entry.put( JSERIALDATA_ATTR, serialize( obj ) );        // Add all the class names this object can be cast to:        Class [] classes = obj.getClass().getClasses();        for ( int ii = 0; ii < classes.length; ii++ )        {            entry.put( JCLASSNAMES_ATTR, classes[ii].getName() );        }    }