From: Tim Slattery on
I'm running a J2EE app in Weblogic. The app works, but I keep getting
this error on the console:

java.rmi.MarshalException: failed to marshal
update(Lweblogic.cluster.replication.ROID;ILjava.io.Serializable;Ljava.lang.Object;);
nested exception is:
java.io.NotSerializableException: java.util.TreeMap$Values

I am storing a TreeMap object in the session object, but the
description of TreeMap says that it implements the Serializable
interface. So why am I getting this error?

--
Tim Slattery
Slattery_T(a)bls.gov
http://members.cox.net/slatteryt
From: Daniel Pitts on
On 2/23/2010 10:28 AM, Tim Slattery wrote:
> I'm running a J2EE app in Weblogic. The app works, but I keep getting
> this error on the console:
>
> java.rmi.MarshalException: failed to marshal
> update(Lweblogic.cluster.replication.ROID;ILjava.io.Serializable;Ljava.lang.Object;);
> nested exception is:
> java.io.NotSerializableException: java.util.TreeMap$Values
>
> I am storing a TreeMap object in the session object, but the
> description of TreeMap says that it implements the Serializable
> interface. So why am I getting this error?
>
The only thing I could think of is if the keys or values of your map
aren't Serializable.

Actually, hmm... I'm not seeing a "Values" class in the TreeMap source
code. At least not in 1.5. Let me double check 1.6...


Ah, I see it in 1.6

The collection returned from TreeMap.values() is not Serializable. You
either need to serialize the whole TreeMap, or copy the values into a
different container.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
From: Roedy Green on
On Tue, 23 Feb 2010 13:28:55 -0500, Tim Slattery <Slattery_T(a)bls.gov>
wrote, quoted or indirectly quoted someone who said :

>nested exception is:
> java.io.NotSerializableException: java.util.TreeMap$Values
>
>I am storing a TreeMap object in the session object, but the
>description of TreeMap says that it implements the Serializable
>interface. So why am I getting this error?

see
http://mindprod.com/jgloss/runerrormessages.html#NOTSERIALIAZABLEEXCEPTION

Not only does TreeMap have to be serializable, but also the keys and
objects you store in it, and the objects those objects point to etc.

values refers to the Collection inside TreeMap of the values ( the
things you look up by key), in other words your objects.
--
Roedy Green Canadian Mind Products
http://mindprod.com

Imagine an architect who would never admit to making sketches, blueprints or erecting scaffolds. In his view, the finished building speaks for itself. How could a young architect learn from such a man? Mathematicians traditionally refuse ever to disclose the intuitions that lead them to a conjecture, or the empirical tests to see if it were likely true, or the initial proofs. They are like chefs who refuse to disclose their recipes, ingredients or techniques.
From: Mike Schilling on

"Roedy Green" <see_website(a)mindprod.com.invalid> wrote in message
news:nbs8o513huanmtsgsjs7dks39o3ukfaimu(a)4ax.com...
> On Tue, 23 Feb 2010 13:28:55 -0500, Tim Slattery <Slattery_T(a)bls.gov>
> wrote, quoted or indirectly quoted someone who said :
>
>>nested exception is:
>> java.io.NotSerializableException: java.util.TreeMap$Values
>>
>>I am storing a TreeMap object in the session object, but the
>>description of TreeMap says that it implements the Serializable
>>interface. So why am I getting this error?
>
> see
> http://mindprod.com/jgloss/runerrormessages.html#NOTSERIALIAZABLEEXCEPTION
>
> Not only does TreeMap have to be serializable, but also the keys and
> objects you store in it, and the objects those objects point to etc.
>
> values refers to the Collection inside TreeMap of the values ( the
> things you look up by key), in other words your objects.

TreeMap$Values is an inner class, the type of the object returned from
TreeMap.values(). It's not used for anything else. In particular, it's not
involved when serializing a TreeMap. It's also not serializable. The only
way to get this error is to attempt to serialize the return from
TreeMap.values(). This will always fail, regardless of the types of the
objects in the map; in fact, it will fail even if the map is empty.


From: Roedy Green on
On Tue, 23 Feb 2010 16:50:43 -0800, "Mike Schilling"
<mscottschilling(a)hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>TreeMap$Values is an inner class, the type of the object returned from
>TreeMap.values(). It's not used for anything else. In particular, it's not
>involved when serializing a TreeMap. It's also not serializable. The only
>way to get this error is to attempt to serialize the return from
>TreeMap.values(). This will always fail, regardless of the types of the
>objects in the map; in fact, it will fail even if the map is empty.

I would call that a bug.

Could Sun fix it just by adding an "implements Serializable" to the
Values nested class?


TreeMap.Values is a private static nested class of TreeMap that
extends AbstractCollection<V>.

--
Roedy Green Canadian Mind Products
http://mindprod.com

The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair.
~ Douglas Adams (born: 1952-03-11 died: 2001-05-11 at age: 49)