Re: [appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
Hi, I have to deploy my project in google appengine.I do not know how to create client and server files. I have referred the SOAP tutorial and but it looks very complicated.Can you suggest any other way or tutorial.I am comfortable with JAVA. Regards, Jyothsna > > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
Thx 4 the detailed example, Will read it at later on today Daniel. On Nov 1, 6:40 pm, Ronoaldo José de Lana Pereira wrote: > Daniel, > > To "convert" old session data I started to persist just the user Id in > session. Sadly, unlike memcache, you can't control how the session is > deserialized. In my case, any request with has the old user data in session > was throwing 500 erros and I couldn't control this behavior (it was a > filter from the gae...). What I did was something like this: > > public MyUser getCurrentUser(HttpServletRequest req) { > Object userOrId = req.getSession().getAttribute("user"); > if (userOrId instanceof Long) { > return loadUserFromDsOrMemcache((Long) userOrId); > } else { > // Remove user from session and start storing ID for next change to > User class dont raise exceptoins ... > User user = (User) userOrId; > req.getSession().setAttribute("user", user.getId()); > return user; > } > > } > > This way I could get rid of storing this in session and of the app being > unacessible when I changed my model (wich was happening heavly by the > way...). Note that at the time I deployed this code, the User object hasn't > changed. > > After running this for a while (you can expire sessions or delete them in > bulk from the datastore so you can force them to expire, I deployed the new > version. > > To store json data, you may use some json library that can map/convert > to/from Java -> Json, like Google Gson: > > String userJson = new Gson().toJson(user); > req.getSession().setAttribute("user", userJson); > (...) > > String userJson = (String) req.getSession().getAttribute("user"); > if (userJson != null) { > User user = new Gson().fromJson(User.class, userJson); > > } > > This way you can add/remove fields to you model, and old session data will > be restored as expected. Note that is a good practice to set defaults for > the new fields, so your session data won't create unusable objects. In your > original post, the change from string to integer may be solved by > overriding the Gson de-serializer to handle the id field as number and not > as string. I guess that you can change the way Java will de-serialize your > classes too, but I'm not sure if this will solve your particular issue > mentioned. > > Not sure if this is the best way to handle, but this is how I solved on our > live app. > > More on Gson:http://code.google.com/p/google-gson/. > > Hope this helps (sorry for some typos or misspelled words) > > Best Regards, > > -Ronoaldo -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
Daniel, To "convert" old session data I started to persist just the user Id in session. Sadly, unlike memcache, you can't control how the session is deserialized. In my case, any request with has the old user data in session was throwing 500 erros and I couldn't control this behavior (it was a filter from the gae...). What I did was something like this: public MyUser getCurrentUser(HttpServletRequest req) { Object userOrId = req.getSession().getAttribute("user"); if (userOrId instanceof Long) { return loadUserFromDsOrMemcache((Long) userOrId); } else { // Remove user from session and start storing ID for next change to User class dont raise exceptoins ... User user = (User) userOrId; req.getSession().setAttribute("user", user.getId()); return user; } } This way I could get rid of storing this in session and of the app being unacessible when I changed my model (wich was happening heavly by the way...). Note that at the time I deployed this code, the User object hasn't changed. After running this for a while (you can expire sessions or delete them in bulk from the datastore so you can force them to expire, I deployed the new version. To store json data, you may use some json library that can map/convert to/from Java -> Json, like Google Gson: String userJson = new Gson().toJson(user); req.getSession().setAttribute("user", userJson); (...) String userJson = (String) req.getSession().getAttribute("user"); if (userJson != null) { User user = new Gson().fromJson(User.class, userJson); } This way you can add/remove fields to you model, and old session data will be restored as expected. Note that is a good practice to set defaults for the new fields, so your session data won't create unusable objects. In your original post, the change from string to integer may be solved by overriding the Gson de-serializer to handle the id field as number and not as string. I guess that you can change the way Java will de-serialize your classes too, but I'm not sure if this will solve your particular issue mentioned. Not sure if this is the best way to handle, but this is how I solved on our live app. More on Gson: http://code.google.com/p/google-gson/. Hope this helps (sorry for some typos or misspelled words) Best Regards, -Ronoaldo -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/kReedxuxpgEJ. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
Thanks for the suggestions, Ian's sounds unrealistic (to me at least) Ronaldo, could you please explain more about the method you are using? or post some references/url's so i could read some more? Thanks! On Oct 30, 10:33 am, Ian Marshall wrote: > You might want to implement an alternative procedure of the following > stages to change the data type of your data mamber = field: > > 1. Add the data member quantityToAddNew of data type Integer. Use > this in your code instead of quantityToAdd. Deploy. > 2. After a suitable delay (at least 24 hours?): change the data type > of the data member quantityToAdd to Integer. Use this in your code > instead of quantityToAddNew. Deploy. > 3. After a suitable delay (at least 24 hours?): remove the data > member quantityToAddNew. Deploy. You're done. > > Enjoy? > > On Oct 29, 11:44 pm, Ronoaldo José de Lana Pereira > > > > > > > > wrote: > > Sine you are talking about _ah_SESSION stuff I suppose you are serializing > > ToBuyBeans to the sessions. On AppEngine, sessions are implemented using a > > combination of datastore and memecache. When you deleted your old session > > data from the datastore, the memcache was still there, and only when they > > got flushed your problem was "automatic" solved. > > > Sadly, I was having this trouble too previously, and the only way to get > > rid of it was to deploy a versions that was trying to fetch data from > > session and "convert" to new format or invalidate the session. This is very > > odd, tought, so I started to store only unchanged data, like a JSON > > representation of you objects, that will never stop your app when you > > change your code and redeploy. Gson and flex-json are good start points, > > apart from the fact that they add some small conversion overhead before > > store data in session. > > > Hope this helps (sorry for typos ... I'm sleepy) > > > -Ronoaldo -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
You might want to implement an alternative procedure of the following stages to change the data type of your data mamber = field: 1. Add the data member quantityToAddNew of data type Integer. Use this in your code instead of quantityToAdd. Deploy. 2. After a suitable delay (at least 24 hours?): change the data type of the data member quantityToAdd to Integer. Use this in your code instead of quantityToAddNew. Deploy. 3. After a suitable delay (at least 24 hours?): remove the data member quantityToAddNew. Deploy. You're done. Enjoy? On Oct 29, 11:44 pm, Ronoaldo José de Lana Pereira wrote: > Sine you are talking about _ah_SESSION stuff I suppose you are serializing > ToBuyBeans to the sessions. On AppEngine, sessions are implemented using a > combination of datastore and memecache. When you deleted your old session > data from the datastore, the memcache was still there, and only when they > got flushed your problem was "automatic" solved. > > Sadly, I was having this trouble too previously, and the only way to get > rid of it was to deploy a versions that was trying to fetch data from > session and "convert" to new format or invalidate the session. This is very > odd, tought, so I started to store only unchanged data, like a JSON > representation of you objects, that will never stop your app when you > change your code and redeploy. Gson and flex-json are good start points, > apart from the fact that they add some small conversion overhead before > store data in session. > > Hope this helps (sorry for typos ... I'm sleepy) > > -Ronoaldo -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
Sine you are talking about _ah_SESSION stuff I suppose you are serializing ToBuyBeans to the sessions. On AppEngine, sessions are implemented using a combination of datastore and memecache. When you deleted your old session data from the datastore, the memcache was still there, and only when they got flushed your problem was "automatic" solved. Sadly, I was having this trouble too previously, and the only way to get rid of it was to deploy a versions that was trying to fetch data from session and "convert" to new format or invalidate the session. This is very odd, tought, so I started to store only unchanged data, like a JSON representation of you objects, that will never stop your app when you change your code and redeploy. Gson and flex-json are good start points, apart from the fact that they add some small conversion overhead before store data in session. Hope this helps (sorry for typos ... I'm sleepy) -Ronoaldo -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/81WIdNaX5HoJ. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
And 1 more thing , the error got fixed by itself, after several hours, the "previously-existing ToBuyBean persistent entities" were somehow deleted (not by me)... so how can i do it by myself if i want to? Thanks ahead On Oct 29, 10:20 pm, Daniel wrote: > The ToBuyBean class indeed implements Serializable , (but its not > stored or persisted in the DB) > > How can I get rid of "previously-existing ToBuyBean persistent > entities?" > > On Oct 28, 10:14 am, Ian Marshall wrote: > > > If you are getting this exception when running on the GAE/J cloud, > > have you deleted all your previously-existing ToBuyBean persistent > > entities? (This would ensure that no ToBuyBean persistent entity > > exists that has a quantityToAdd already persisted as a string.) > > > On Oct 27, 10:14 pm, Daniel wrote: > > > > HI > > > > I'm getting > > > > Nested in javax.servlet.ServletException: > > > java.lang.ClassCastException: cannot assign instance of > > > java.lang.String to field dr.todo.beans.ToBuyBean.quantityToAdd of > > > type java.lang.Integer in instance of dr.todo.beans.ToBuyBean: > > > > cause I had a String and now i changed it to Integer and updated my > > > application, and i deleted all _ah_SESSION entrys, but it still does > > > not work... > > > > how can i properly get rid of all the Zombie data upon updating my > > > application from eclipse? > > > > I don't want to wait for couple of hours , I want to get rid of all > > > the Zombies right after the upgrade... > > > > What is the best practice for it? > > > > Thanks ahead, > > > > Daniel. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
The ToBuyBean class indeed implements Serializable , (but its not stored or persisted in the DB) How can I get rid of "previously-existing ToBuyBean persistent entities?" On Oct 28, 10:14 am, Ian Marshall wrote: > If you are getting this exception when running on the GAE/J cloud, > have you deleted all your previously-existing ToBuyBean persistent > entities? (This would ensure that no ToBuyBean persistent entity > exists that has a quantityToAdd already persisted as a string.) > > On Oct 27, 10:14 pm, Daniel wrote: > > > HI > > > I'm getting > > > Nested in javax.servlet.ServletException: > > java.lang.ClassCastException: cannot assign instance of > > java.lang.String to field dr.todo.beans.ToBuyBean.quantityToAdd of > > type java.lang.Integer in instance of dr.todo.beans.ToBuyBean: > > > cause I had a String and now i changed it to Integer and updated my > > application, and i deleted all _ah_SESSION entrys, but it still does > > not work... > > > how can i properly get rid of all the Zombie data upon updating my > > application from eclipse? > > > I don't want to wait for couple of hours , I want to get rid of all > > the Zombies right after the upgrade... > > > What is the best practice for it? > > > Thanks ahead, > > > Daniel. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Change from String to Integer , now can't rid of Zombie instances... what is the right procedure to do so?
If you are getting this exception when running on the GAE/J cloud, have you deleted all your previously-existing ToBuyBean persistent entities? (This would ensure that no ToBuyBean persistent entity exists that has a quantityToAdd already persisted as a string.) On Oct 27, 10:14 pm, Daniel wrote: > HI > > I'm getting > > Nested in javax.servlet.ServletException: > java.lang.ClassCastException: cannot assign instance of > java.lang.String to field dr.todo.beans.ToBuyBean.quantityToAdd of > type java.lang.Integer in instance of dr.todo.beans.ToBuyBean: > > cause I had a String and now i changed it to Integer and updated my > application, and i deleted all _ah_SESSION entrys, but it still does > not work... > > how can i properly get rid of all the Zombie data upon updating my > application from eclipse? > > I don't want to wait for couple of hours , I want to get rid of all > the Zombies right after the upgrade... > > What is the best practice for it? > > Thanks ahead, > > Daniel. -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.