0

I am trying to build a GWT/SmartClient widget which accepts a set of items which will be rendered into a dashboard... depending on the exact item type, it may render as a grid, a chart, a label, etc. The abstract class is

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

Currently, I am only trying to implement an item which knows how to render a DataSource (turn it into a grid):

public class DashboardGridItem extends DashboardItem<DataSource> {

    public DashboardGridItem(DataSource datasource) {
        super(datasource);
    }

    @Override
    public Widget render(DataSource datasource) {
         ...
    }
}

This all seems to be ok. Now, I have a class which I wish to use to fetch the dashboard items from some source... eventually, I want this to be a database but for now its just a hard coded empty array. Here is the class:

public class DashboardService {
    public List<DashboardItem<?>> getDashboardItems() {
        return new ArrayList<DashboardItem<?>>();
    }
}

The problem I am having is that I am always receiving a ClassDefNotFound error for the above class despite the fact that is it sitting in the same project as the rest of my code. There is nothing obvious to me about why this would not be allowed in client code... I have tried getting rid of the wildcards, but I still get the same error.

Anybody have any ideas? Do I have a major brain fart going on here?

As requested, the stacktrace:

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
jcampos8782
  • 3,956
  • 4
  • 22
  • 23
  • stacktrace or didn't happen. What is `DataSource`, what class is not found, did you respect the client/server aspect (i.e. client sources must be convertible to javascript) –  Aug 15 '13 at 06:14
  • 1
    I tried the same and it works perfectly. Must be that your DashboardService class is in the server package, and not in the client package. – mlkammer Aug 15 '13 at 11:43
  • I also tried your code and it works for me. I join the above questions. It might help if you provide StackTrace. – Artem Aug 15 '13 at 11:56
  • Sure, I can get a stacktrace up a bit later. Actually, DashboardService is in the client package, not the server. Maybe something wonky going on in my environment... I can't seem to figure out what in DashboardService is offending the GWT compiler... no useful output from the compiler, even in Debug. – jcampos8782 Aug 15 '13 at 14:12
  • @RC: DataSource doc from SmartClient: http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/DataSource.html – jcampos8782 Aug 15 '13 at 14:13

1 Answers1

0

Holy moly... the problem was that somehow a package named 'server' was put into the client code. There are actually two projects: xxx-client and xxx-server. All of the server stuff is in one and the client in the other. Somehow, this server package ended up in the client code.

Ugh... how dumb

jcampos8782
  • 3,956
  • 4
  • 22
  • 23