我正在尝试构建一个 GWT/SmartClient 小部件,它接受一组将呈现到仪表板中的项目...根据确切的项目类型,它可能呈现为网格、图表、标签等。摘要类是
public abstract class DashboardItem<T> implements IsWidget {
public abstract Widget render(T t);
private T t;
public DashboardItem(T t) {
this.t = t;
}
@Override
public Widget asWidget() {
return render(t);
}
}
目前,我只是在尝试实现一个知道如何呈现 DataSource 的项目(将其变成网格):
public class DashboardGridItem extends DashboardItem<DataSource> {
public DashboardGridItem(DataSource datasource) {
super(datasource);
}
@Override
public Widget render(DataSource datasource) {
...
}
}
这一切似乎都还好。现在,我有一个类,我希望使用它从某个来源获取仪表板项目......最终,我希望这是一个数据库,但现在它只是一个硬编码的空数组。这是课程:
public class DashboardService {
public List<DashboardItem<?>> getDashboardItems() {
return new ArrayList<DashboardItem<?>>();
}
}
我遇到的问题是,我总是收到上述类的 ClassDefNotFound 错误,尽管事实上它与我的其他代码位于同一个项目中。关于为什么在客户端代码中不允许这样做对我来说没有什么明显的......我已经尝试摆脱通配符,但我仍然得到同样的错误。
有人有什么想法吗?我这里是不是脑子里放了个大屁?
根据要求,堆栈跟踪:
08/14/2013 21:42:09 Uncaught Exception intercepted
com.google.web.bindery.event.shared.UmbrellaException: Exception caught: com/trackmysports/server/service/impl/DashboardService
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:203)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.trackmysports.client.GeneralPage$3$1.onSuccess(GeneralPage.java:343)
at com.trackmysports.client.GeneralPage$3$1.onSuccess(GeneralPage.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: com/trackmysports/server/service/impl/DashboardService
at com.trackmysports.client.ContentPanelFactory.getContentPanel(ContentPanelFactory.java:80)
at com.trackmysports.client.TrackMySports$3.onLogin(TrackMySports.java:91)
at com.trackmysports.client.events.LoginEvent.dispatch(LoginEvent.java:27)
at com.trackmysports.client.events.LoginEvent.dispatch(LoginEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
... 32 more
Caused by: java.lang.ClassNotFoundException: com.trackmysports.server.service.impl.DashboardService
at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1090)
at com.google.gwt.dev.shell.CompilingClassLoader.loadClass(CompilingClassLoader.java:1196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 39 more