Hi Ikai:
The issue is happening in production.
the code for UserDetails is as given below:
@SuppressWarnings("serial")
public class UserDetails implements Serializable {
private String userKey;
private String instanceID;
private String userName;
private String email;
private String firstName;
private String lastName;
private Boolean superUser;
private String tag;
private AddressDTO address;
private Date lastVisit;
public Boolean getSuperUser() {
return superUser;
}
public void setSuperUser(Boolean superUser) {
this.superUser = superUser;
}
public String getInstanceID() {
return instanceID;
}
public void setInstanceID(String tenantID) {
this.instanceID = instanceID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public UserDetails() {
super();
// TODO Auto-generated constructor stub
}
public String getUserKey() {
return userKey;
}
public void setUserKey(String userKey) {
this.userKey = userKey;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public AddressDTO getAddress() {
return address;
}
public void setAddress(AddressDTO address) {
this.address = address;
}
public Date getLastVisit() {
return lastVisit;
}
public void setLastVisit(Date lastVisit) {
this.lastVisit = lastVisit;
}
public String getFullName() {
return new StringBuffer(firstName).append(" ").append(lastName)
.toString();
}
public UserDetails(String userKey, String instanceID, String
userName,
String email, String firstName, String lastName,
Boolean superUser,
String tag, AddressDTO address) {
super();
this.instanceID = instanceID;
this.userName = userName;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.userKey = userKey;
this.superUser = superUser;
this.tag = tag;
this.address = address;
}
}
It would be great if you an let me know what the issue is.
On Mar 1, 11:05 am, "Ikai Lan (Google)" <[email protected]>
wrote:
> Is this something that happens locally, or in production? I haven't tried
> the code, but my suspicions are:
>
> 1. Something is happened with the serialization of the object when it's
> being saved. Could this value be set elsewhere?
> 2. The generics are breaking serialization. This seems strange to me, though
>
> Can you post UserDetails?
>
> If you aren't keen to solve this, another workaround would be to simply
> write your own serialization and deserialization code via JSON or protobuf.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> Blogger:http://googleappengine.blogspot.com
> Reddit:http://www.reddit.com/r/appengine
> Twitter:http://twitter.com/app_engine
>
> On Mon, Feb 28, 2011 at 10:01 PM, GWTNewbie <[email protected]> wrote:
> > 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.
--
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.