Hello:
I am using memcache to keep track of logged users in an app that I am
building. However when I do a GET on the memcache I get an exception:

exception: java.lang.ClassCastException: java.util.ArrayList cannot be
cast to java.util.HashMap

>From the logs it appears that the exception is caused by the
statement:
                HashMap<String, UserDetails> userMap = (HashMap<String,
UserDetails>) _cache
                                .get(user.getInstance());
in the method logOn.

Any ideas as to what the issue could be ?
---------------------------------
Code snippet below:

import com.samuuhanet.main.shared.UserDetails;

public class LoggedUsers {
        private static LoggedUsers _cacheInstance;
        private static boolean _invalidationDone = false;

        private Cache _cache;

        public static final Logger _log = Logger.getLogger(LoggedUsers.class
                        .getName());

        private LoggedUsers() {
                try {
                        CacheFactory cacheFactory = CacheManager.getInstance()
                                        .getCacheFactory();

                        _cache = 
cacheFactory.createCache(Collections.emptyMap());
                } catch (CacheException e) {
                        // Log stuff
                        _log.log(Level.WARNING, "Error in creating the Cache");
                }

        }

        public static synchronized LoggedUsers getInstance() {
                if (_cacheInstance == null) {
                        _cacheInstance = new LoggedUsers();
                }
                return _cacheInstance;
        }

        public void logOn(UserDetails user) {

                if (_cache == null)
                        return;

                HashMap<String, UserDetails> userMap = (HashMap<String,
UserDetails>) _cache
                                .get(user.getInstance());
                // Check if user already exists
                if (userMap == null) {
                        userMap = new HashMap<String, UserDetails>();
                }

                userMap.put(user.getUserName(), user);
                _cache.put(user.getInstanceID(), userMap);
        }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to