Skip to main content

NotSerializableException

java.io.NotSerializableException

NotSerializableException is described in the javadoc comments as:

Thrown when an instance is required to have a Serializable interface. The serialization runtime or the class of the instance can throw this exception. The argument should be the name of the class.
author: unascribed version: 1.14, 12/19/03 since: JDK1.1

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

com.sun.corba.se.impl.io.IIOPOutputStream.outputObject(Object)

private void outputObject(final Object obj) throws IOException {
    currentObject = obj;
    Class currclass = obj.getClass();
    currentClassDesc = ObjectStreamClass.lookup(currclass);
    if (currentClassDesc == null) {
        throw new NotSerializableException(currclass.getName());
    }
    if (currentClassDesc.isExternalizable()) {
        orbStream.write_octet(streamFormatVersion);
        Externalizable ext = (Externalizable) obj;
        ext.writeExternal(this);
    } else {
        int stackMark = classDescStack.size();
        try {
            ObjectStreamClass next;
            while ((next = currentClassDesc.getSuperclass()) != null) {
                classDescStack.push(currentClassDesc);
                currentClassDesc = next;
            }
            do {
                WriteObjectState oldState = writeObjectState;
                try {
                    setState(NOT_IN_WRITE_OBJECT);
                    if (currentClassDesc.hasWriteObject()) {
                        invokeObjectWriter(currentClassDesc, obj);
                    } else {
                        defaultWriteObjectDelegate();
                    }
                } finally {
                    setState(oldState);
                }
            } while (classDescStack.size() > stackMark && (currentClassDesc = (ObjectStreamClass) classDescStack.pop()) != null);
        } finally {
            classDescStack.setSize(stackMark);
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.xerces.internal.dom.PSVIAttrNSImpl.readObject(ObjectInputStream)

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    throw new NotSerializableException(getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.xerces.internal.dom.PSVIAttrNSImpl.writeObject(ObjectOutputStream)

private void writeObject(ObjectOutputStream out) throws IOException {
    throw new NotSerializableException(getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.xerces.internal.dom.PSVIDocumentImpl.readObject(ObjectInputStream)

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    throw new NotSerializableException(getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.xerces.internal.dom.PSVIDocumentImpl.writeObject(ObjectOutputStream)

private void writeObject(ObjectOutputStream out) throws IOException {
    throw new NotSerializableException(getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl.readObject(ObjectInputStream)

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    throw new NotSerializableException(getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl.writeObject(ObjectOutputStream)

private void writeObject(ObjectOutputStream out) throws IOException {
    throw new NotSerializableException(getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.ObjectOutputStream.writeObject0(Object, boolean)

/**
     * Underlying writeObject/writeUnshared implementation.
     */
private void writeObject0(Object obj, boolean unshared) throws IOException {
    boolean oldMode = bout.setBlockDataMode(false);
    depth++;
    try {
        int h;
        if ((obj = subs.lookup(obj)) == null) {
            writeNull();
            return;
        } else if (!unshared && (h = handles.lookup(obj)) != -1) {
            writeHandle(h);
            return;
        } else if (obj instanceof Class) {
            writeClass((Class) obj, unshared);
            return;
        } else if (obj instanceof ObjectStreamClass) {
            writeClassDesc((ObjectStreamClass) obj, unshared);
            return;
        }
        Object orig = obj;
        Class cl = obj.getClass();
        ObjectStreamClass desc;
        for (; ; ) {
            Class repCl;
            desc = ObjectStreamClass.lookup(cl, true);
            if (!desc.hasWriteReplaceMethod() || (obj = desc.invokeWriteReplace(obj)) == null || (repCl = obj.getClass()) == cl) {
                break;
            }
            cl = repCl;
        }
        if (enableReplace) {
            Object rep = replaceObject(obj);
            if (rep != obj && rep != null) {
                cl = rep.getClass();
                desc = ObjectStreamClass.lookup(cl, true);
            }
            obj = rep;
        }
        if (obj != orig) {
            subs.assign(orig, obj);
            if (obj == null) {
                writeNull();
                return;
            } else if (!unshared && (h = handles.lookup(obj)) != -1) {
                writeHandle(h);
                return;
            } else if (obj instanceof Class) {
                writeClass((Class) obj, unshared);
                return;
            } else if (obj instanceof ObjectStreamClass) {
                writeClassDesc((ObjectStreamClass) obj, unshared);
                return;
            }
        }
        if (obj instanceof String) {
            writeString((String) obj, unshared);
        } else if (cl.isArray()) {
            writeArray(obj, desc, unshared);
        } else if (obj instanceof Enum) {
            writeEnum((Enum) obj, desc, unshared);
        } else if (obj instanceof Serializable) {
            writeOrdinaryObject(obj, desc, unshared);
        } else {
            throw new NotSerializableException(cl.getName());
        }
    } finally {
        depth--;
        bout.setBlockDataMode(oldMode);
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.swing.plaf.synth.SynthLookAndFeel.writeObject(java.io.ObjectOutputStream)

private void writeObject(java.io.ObjectOutputStream out) throws IOException {
    throw new NotSerializableException(this.getClass().getName());
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.swing.text.StyleContext.writeAttributeSet(ObjectOutputStream, AttributeSet)

/**
     * Writes a set of attributes to the given object stream
     * for the purpose of serialization.  This will take
     * special care to deal with static attribute keys that
     * have been registered wit the 
     * <code>registerStaticAttributeKey</code> method.
     * Any attribute key not regsitered as a static key
     * will be serialized directly.  All values are expected
     * to be serializable.
     * @param out the output stream
     * @param a the attribute set
     * @exception IOException on any I/O error
     */
public static void writeAttributeSet(ObjectOutputStream out, AttributeSet a) throws IOException {
    int n = a.getAttributeCount();
    out.writeInt(n);
    Enumeration keys = a.getAttributeNames();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof Serializable) {
            out.writeObject(key);
        } else {
            Object ioFmt = freezeKeyMap.get(key);
            if (ioFmt == null) {
                throw new NotSerializableException(key.getClass().getName() + ' is not serializable as a key in an AttributeSet');
            }
            out.writeObject(ioFmt);
        }
        Object value = a.getAttribute(key);
        Object ioFmt = freezeKeyMap.get(value);
        if (value instanceof Serializable) {
            out.writeObject((ioFmt != null) ? ioFmt : value);
        } else {
            if (ioFmt == null) {
                throw new NotSerializableException(value.getClass().getName() + ' is not serializable as a value in an AttributeSet');
            }
            out.writeObject(ioFmt);
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.prefs.NodeChangeEvent.readObject(java.io.ObjectInputStream)

/**
     * Throws NotSerializableException, since NodeChangeEvent objects are not
     * intended to be serializable.
     */
private void readObject(java.io.ObjectInputStream in) throws NotSerializableException {
    throw new NotSerializableException('Not serializable.');
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.prefs.NodeChangeEvent.writeObject(java.io.ObjectOutputStream)

/**
     * Throws NotSerializableException, since NodeChangeEvent objects are not
     * intended to be serializable.
     */
private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException {
    throw new NotSerializableException('Not serializable.');
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.prefs.PreferenceChangeEvent.readObject(java.io.ObjectInputStream)

/**
     * Throws NotSerializableException, since PreferenceChangeEvent objects 
     * are not intended to be serializable.
     */
private void readObject(java.io.ObjectInputStream in) throws NotSerializableException {
    throw new NotSerializableException('Not serializable.');
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.prefs.PreferenceChangeEvent.writeObject(java.io.ObjectOutputStream)

/**
     * Throws NotSerializableException, since NodeChangeEvent objects
     * are not intended to be serializable.
     */
private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException {
    throw new NotSerializableException('Not serializable.');
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.security.KeyRep.readResolve()

/**
     * Resolve the Key object.
     *  This method supports three Type/format combinations:
     * <ul>
     * <li> Type.SECRET/'RAW' - returns a SecretKeySpec object
     * constructed using encoded key bytes and algorithm
     * <li> Type.PUBLIC/'X.509' - gets a KeyFactory instance for
     * the key algorithm, constructs an X509EncodedKeySpec with the
     * encoded key bytes, and generates a public key from the spec
     * <li> Type.PRIVATE/'PKCS#8' - gets a KeyFactory instance for
     * the key algorithm, constructs a PKCS8EncodedKeySpec with the
     * encoded key bytes, and generates a private key from the spec
     * </ul>
     * 
     * @return the resolved Key object
     * @exception NotSerializableException if the Type/format
     * combination is unrecognized, if the algorithm, key format, or
     * encoded key bytes are unrecognized/invalid, of if the
     * resolution of the key fails for any reason
     */
protected Object readResolve() throws ObjectStreamException {
    try {
        if (type == Type.SECRET && RAW.equals(format)) {
            return new SecretKeySpec(encoded, algorithm);
        } else if (type == Type.PUBLIC && X509.equals(format)) {
            KeyFactory f = KeyFactory.getInstance(algorithm);
            return f.generatePublic(new X509EncodedKeySpec(encoded));
        } else if (type == Type.PRIVATE && PKCS8.equals(format)) {
            KeyFactory f = KeyFactory.getInstance(algorithm);
            return f.generatePrivate(new PKCS8EncodedKeySpec(encoded));
        } else {
            throw new NotSerializableException('unrecognized type/format combination: ' + type + '/' + format);
        }
    } catch (NotSerializableException nse) {
        throw nse;
    } catch (Exception e) {
        NotSerializableException nse = new NotSerializableException('java.security.Key: ' + '[' + type + '] ' + '[' + algorithm + '] ' + '[' + format + ']');
        nse.initCause(e);
        throw nse;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Comments

Popular posts from this blog

Connection refused: No available router to destination

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators.
Symptom

The following exception occurs in WebLogic server logs. Most likely to occur during WebLogic server start-up, but similar exceptions may occur at other times.
java.net.ConnectException: t3://myserver:8000: Destination unreachable; nested exception is: java.net.ConnectException: Connection refused: connect; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:49) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277)
Cause
This message (Connection refused: connect; No available router to destination) is a kind of "catch…

BAD_CERTIFICATE - A corrupt or unuseable certificate...

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators.
Symptom
In wls_utc, when trying to test a webservice using SSL, the following error message is received: javax.net.ssl.SSLKeyException: FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificate was received.
If SSL debugging is enabled, the following error also appears in the logs: ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)' <1254822672320>>
verification failed because RSA key public exponent [3] is too small
Cause
The certificate encryption is of a weaker strength than expected by newer versions of Java.
Solution
Add the flag "-Dweblogic.security.SSL.allowSmallRSAExponent=true" to the server startup parameters.
References


None.

WebLogic Admin Console

WebLogic Admin Console
The WebLogic Admin Console is a web-based, user interface used to configure and control a set of WebLogic servers or clusters (i.e. a "domain"). In any logical group of WebLogic servers there must exist one admin server, which hosts the WebLogic Admin Console application and manages the associated configuration files.
WebLogic Administrators will use the Administration Console for a number of tasks, including:
Starting and stopping WebLogic servers or entire clusters.Configuring server parameters, security, database connections and deployed applications.Viewing server status, health and metrics. Note: It is not strictly necessary to use the Weblogic Admin Console to perform these tasks, as they can be scripted using WLST (the WebLogic Scripting Tool).
Accessing the Admin Console
WebLogic Admin Console Url: http://hostname:port/console.
To access the WebLogic Administration Console, assuming the admin server has been started, goto the above url. Where hostname…