I'm using GWT for a class project, and although everything worked before, I recently refactored my code and suddenly I'm running into the title error. I searched around and it seems that the GWTBridge problem is caused by 2 main things: a) a bug which was fixed for 2.5.1, or b) trying to call client-side code from the server and vice versa (classNotFoundException GWTBridge).
I'm using GWT 2.5.1 and I'm 99% sure I'm not violating case b), so I'm at a loss. I literally just copy and pasted code from the working version while refactoring, so I'm not sure where the problem is coming from.
My intuition is that it may have something to do with two static Singleton classes I created while refactoring. My objective when refactoring was simply to make RPCs less messy, as it was forcing me to chain a bunch of asynchronous calls which drove me crazy. What I basically did was to make two static Singleton classes (PageLoader and UserManager) whose purposes were to make the asynchronous calls and return whatever OnSuccess returned, so that in onModuleLoad I could make successive RPC calls without having to deal with chaining (e.g. I could just go UserManager.getInstance().isLoggedIn() and then used the returned boolean in an RPC call later on without having to put that call inside an onSuccess function). I put both these classes in client.services along with my Async classes.
I have no idea why that might cause a problem, but I can't think of anything else. Does know if I'm on the right track?
I've attached one of the static classes and part of the returned stack trace below.
UserManager Class
package com.google.gwt.sample.vendorcouver.client.services;
import com.google.gwt.core.client.GWT;
import com.google.gwt.sample.vendorcouver.client.user.VenUser;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
/*Singleton that simplifies making asynchronous calls to the server side.*/
public class UserManager {
private static UserManager UserManagerInstance = null;
private static LoginServiceAsync LoginServiceInstance = null;
private static VenUserServiceAsync VenUserServiceInstance = null;
private static boolean isLoggedIn = false;
private static boolean isAdmin = false;
private static String UserName = null;
public static UserManager getInstance()
{
if (UserManagerInstance == null)
{
UserManagerInstance = new UserManager();
LoginServiceInstance = GWT.create(LoginService.class);
VenUserServiceInstance = GWT.create(VenUserService.class);
}
return UserManagerInstance;
}
public boolean isLoggedIn()
{
LoginServiceInstance.isLoggedIn(new AsyncCallback<Boolean>() {
public void onFailure(Throwable error) {
Window.alert("Sorry, there seemed to be an error on the server side! You may be unable to log in.");
}
public void onSuccess(Boolean loggedInStatus) {
Window.alert("isLoggedIn is sucessful; will return" + loggedInStatus);
isLoggedIn = loggedInStatus;
}
});
return isLoggedIn;
}
Stack trace:
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract boolean com.google.gwt.sample.vendorcouver.client.services.LoginService.isLoggedIn()' threw an unexpected exception: java.lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:487)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge
at com.google.gwt.user.client.Window.<clinit>(Window.java:504)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at com.google.gwt.sample.vendorcouver.server.LoginServiceImpl.isLoggedIn(LoginServiceImpl.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 40 more
Caused by: java.lang.ClassNotFoundException: com.google.gwt.core.client.GWTBridge
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 52 more