[Red5] New error since 6.0rc to 6.1 with IScope.getAttribute() ?
jojo at struktur.de
Mon Jun 4 19:26:32 EDT 2007
Guillaume Lecanu schrieb:
> Is anybody can help me about this change between 6.0rc to 6.1 please ?
> 2007/5/30, Guillaume Lecanu <Guillaume at lya.fr <mailto:Guillaume at lya.fr>>:
> [ERROR] 15858 pool-3-thread-1:( RTMPHandler.onInvoke ) Error connecting
> java.lang.ClassCastException: java.util.LinkedHashMap
> Hashtable publishers = new Hashtable();
> app.setAttribute("publishers", publishers);
> publishers = (Hashtable)app.getAttribute("publishers");
you should always use the generic classes like "Hash" or "List" when
getting attributes from a Red5 object. The attributes are serialized
similar to how AMF0 objects are handled, so for these types, the exact
class is lost.
Thus, a better approach would be:
----- snip -----
Hashtable publishers = new Hashtable();
Map publishers2 = app.getMapAttribute("publishers");
Map publishers3 = (Map) app.getAttribute("publishers");
----- snap -----
Hope that helps,
BTW: This has been since the first version of the persistence code, so
I can't imagine how the "Hashtable" code worked before... Maps were
always loaded as "HashMap" or "LinkedHashMap".
More information about the Red5