Well, the problem was due to the tomcat classloader. Not sure why, but when i packaged the memcached jar in the war file (It had been in tomcat's top level lib directory) it worked! Not a GWT issue. ;-)
-Jeremiah On Mon, Nov 24, 2008 at 3:11 PM, Jeremiah Elliott <[EMAIL PROTECTED]>wrote: > Ok, still having issues with this... Has anyone here used memcached with > gwt? I am starting to thing the problem is because the Report object is both > IsSerializable and java.io.Serializable? Any kind of pointer would be > good. Thanks > -Jeremiah > > > On Sat, Nov 22, 2008 at 1:10 PM, Jeremiah Elliott <[EMAIL PROTECTED]>wrote: > >> ok, I am not even 100% sure this is a GWT issue. The more I mess with it >> the more I am convinced that it is somehow gwt related. Anyway I am in the >> process of adding memcache to the application I am working on. In hosted >> mode it worked exactly as expected. Huge speed improvement, and the >> memcached log shows my objects going in and out as expected. The problem is >> that when i publish the application to tomcat the cache doesn't work. I can >> still add items to the cache, but when i pull items out of the cache I get a >> class not found exception. >> Initially I thought that the problem may be because the object being >> cached lives in the client package. (com.sagus.client.Report) I createdd a >> shared package as discribed here >> >> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/51a8a9bb3f141ab4/c43fcc7dad3f7fde?lnk=gst&q=foo.bar.shared#c43fcc7dad3f7fde >> however this didnt' solve the problem. I could still set and get the >> Report object in Hosted Mode but in production on tomcat I got the same >> message. Here is the stacktrace: >> java.lang.ClassNotFoundException: com.sagus.Shared.Report >> at java.net.URLClassLoader$1.run(URLClassLoader.java:200) >> at java.security.AccessController.doPrivileged(Native Method) >> at java.net.URLClassLoader.findClass(URLClassLoader.java:188) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:307) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:252) >> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) >> at java.lang.Class.forName0(Native Method) >> at java.lang.Class.forName(Class.java:247) >> ...... >> >> >> >> Well, clearly it can find com.sagus.Shared.Report because is putting it >> into memcache just fine. In a last act of desperation, i exported the >> contents of src into a jar file using eclipse export feature, and dumped >> that into Tomcat's lib directory. Now I am getting a ClassCastException: >> >> 2008-11-22 12:33:57,425 : ERROR : >> com.sagus.server.DataCache.getWidget(DataCache.java:27) : get widget 18: >> java.lang.ClassCastException: com.sagus.Shared.Report cannot be cast to >> com.sagus.Shared.Report >> at com.sagus.server.DataCache.getWidget(DataCache.java:25) >> at >> com.sagus.server.SagusDashImpl.getReportById(SagusDashImpl.java:244) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527) >> at >> com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164) >> at >> com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86) >> ...... >> >> >> >> >> This is the class I am using to do the memcache sets and gets: >> >> package com.sagus.server; >> >> import java.io.IOException; >> import java.net.InetSocketAddress; >> import net.spy.memcached.MemcachedClient; >> import org.apache.log4j.Logger; >> import com.sagus.Shared.Report; >> >> public class DataCache { >> private static final Logger logger = >> SagusDashImpl.getLogger(); >> private static String WIDGET_PREFIX = "PROD_WIDGET_"; >> private static MemcachedClient c = null; >> >> public DataCache() { >> try { >> c = new MemcachedClient(new InetSocketAddress("localhost", >> 11211)); >> } catch (IOException ioe) { >> logger.error("init DataCache ", ioe); >> } >> } >> >> public Report getWidget(int id) { >> Report r = null; >> try { >> r = (Report) c.get(WIDGET_PREFIX + id); >> } catch (Exception e) { >> logger.error("get widget " + id + ": ", e); >> } >> return r; >> } >> >> public void cacheWidget(Report report) { >> try { >> c.set(WIDGET_PREFIX + report.getWidgetId(), 360000, report); >> } catch (Exception e) { >> logger.error("cacheWidget ", e); >> } >> } >> >> >> Here is the object being cached, its just a pojo: >> >> package com.sagus.Shared; >> import java.util.ArrayList; >> import java.util.Date; >> import com.google.gwt.user.client.rpc.IsSerializable; >> >> public class Report implements IsSerializable, java.io.Serializable { >> .... >> } >> >> >> On one hand I wonder if its because it is implementing two different >> serializable interfaces, but when i build this same object from the database >> it works just fine. >> At this point I am totally out of ideas. Any pointers would be helpful. >> >> -Jeremiah >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
