gpt4 book ai didi

java - GWT 错误 : java. lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge

转载 作者:行者123 更新时间:2023-11-30 08:24:46 26 4
gpt4 key购买 nike

我正在为一个类项目使用 GWT,虽然之前一切正常,但我最近重构了我的代码,突然遇到了标题错误。我四处搜索,似乎 GWTBridge 问题是由 2 个主要问题引起的:a) 为 2.5.1 修复的错误,或 b) 试图从服务器调用客户端代码,反之亦然(classNotFoundException GWTBridge) .

我使用的是 GWT 2.5.1,我 99% 确定我没有违反情况 b),所以我不知所措。我实际上只是在重构时从工作版本复制和粘贴代码,所以我不确定问题出在哪里。

我的直觉是,它可能与我在重构时创建的两个静态 Singleton 类有关。重构时我的目标只是让 RPC 不那么困惑,因为它迫使我链接一堆异步调用,这让我发疯。我基本上做的是制作两个静态单例类(PageLoader 和 UserManager),它们的目的是进行异步调用并返回 OnSuccess 返回的任何内容,这样在 onModuleLoad 中我可以进行连续的 RPC 调用而不必处理链接(例如我可以只需转到 UserManager.getInstance().isLoggedIn() ,然后在稍后的 RPC 调用中使用返回的 boolean 值,而不必将该调用放在 onSuccess 函数中)。我将这两个类与异步类一起放在 client.services 中。

我不知道为什么这会导致问题,但我想不出其他任何事情。知道我是否在正确的轨道上吗?

我在下面附加了一个静态类和部分返回的堆栈跟踪。


用户管理类

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;
}

堆栈跟踪:

   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

最佳答案

堆栈跟踪很清楚:您正在尝试使用 com.google.gwt.sample 中的 com.google.gwt.user.client.Window(客户端)类。 vendorcouver.server.LoginServiceImpl#isLoggedIn(服务器端代码)


顺便说一句,您确实意识到您的 UserManager#isLoggedIn 在第一次被调用时总是返回false,对吧? (由于 RPC 调用的异步性质)

关于java - GWT 错误 : java. lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22707020/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com