replace-with problem

86 views
Skip to first unread message

ailinykh

unread,
Nov 7, 2011, 10:40:00 AM11/7/11
to google-we...@googlegroups.com
Hello everybody!
I have three GWT modules A, B and C. C has some common widgets and utility classes/interfaces.
both A and B depends on C. A depends on B. A has an entry point.

The problem is: module C has an interface which I want to replace by a class in A module. I use replace-with statement in A.gwt.xml file.
If I use this interface from module A  ( GWT.create(MyInterface.class) ) everything is fine, but when I do the same in module B I get "Deferred binding failed" exception. I guess it happens because module B doesn't have replace-with statement in B.gwt.xml file.
But I don't want (and actually can't) have two implementations (one in A, another in B).
Is there any way to fix this problem?

Thank you,
  Andrey

Thomas Broyer

unread,
Nov 8, 2011, 4:20:06 AM11/8/11
to google-we...@googlegroups.com
You said that "A has an entry point", so A is your app, and B and C are only libraries. That means B cannot be compiled on its own, it needs to be inherited by an "app" module, which will have the responsibility of defining a rebind rule (as you did in A).
So, I don't understand what you mean by "when I do the same in module B"? Either your compiling A, and all is OK; or you compiling another module, and it has to provide a rebind rule. The location in your code where you GWT.create() the interface doesn't matter (i.e. it doesn't matter that your code in com.mycompany.moduleB.client GWT.create()s the interface when the rebind rule is defined in com.mycompany.moduleA.ModuleA.gwt.xml); but there must be a rebind rule in the module (including its inherited modules) that you pass to the GWT compiler.

Thomas Broyer

unread,
Nov 8, 2011, 11:52:28 AM11/8/11
to Google Web Toolkit, ailinykh
[back to the group]

On Tue, Nov 8, 2011 at 5:39 PM, ailinykh <aili...@gmail.com> wrote:
> I meant run time error. I want module B (which is a library) to use
> implementation defined in app (module A). Let's say this is error message
> screen, it could be pop up, separated page, what ever. So all code is
> written against  ErrorScreenInterface. I define implementation in app-
> PopUpErrorScreen.
> Module B has code- GWT.create(ErrorScreenInterface.class). And it fails here
> because module B doesn't depend on A.
> It doesn't know how to create PopUpErrorScreen. I get class not found
> exception.
> This is my problem.

So, does your app compile? (GWT compiler)

As I said, it doesn't matter in which class the GWT.create() is done,
and in which gwt.xml the <replace-with> rule is defined. If you see a
ClassNotFoundException, it's probably a classpath or <source/> path
issue.

Can you copy/paste the errors from the DevMode console, and your
DevMode launch configuration?

ailinykh

unread,
Nov 8, 2011, 12:27:26 PM11/8/11
to google-we...@googlegroups.com, Google Web Toolkit, ailinykh
Yes, I can compile. I get ClassNotFoundException when in module B (library) I try to create interface replaced by concrete class in app.

09:17:51.405 [ERROR] [myapp] Could not load deferred binding result type 'com.ais.myapp.client.ExceptionHandlerImpl'

java.lang.ClassNotFoundException: com$ais$myapp$client$ExceptionHandlerImpl
    at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1061)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.google.gwt.dev.shell.ModuleSpace.loadClassFromSourceName(ModuleSpace.java:654)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:458)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
    09:17:51.558 [ERROR] [ratemovies] Uncaught exception escaped

and one more 

java.lang.RuntimeException: Deferred binding failed for 'com.ais.gwt.client.core.ExceptionHandler' (did you forget to inherit a required module?)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
    at com.google.gwt.core.client.GWT.create(GWT.java:97)
    at com.ais.gwt.client.MyCallback.onFailure(MyCallback.java:21)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:237)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    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:213)
    at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Thread.java:679)
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:503)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
    at com.google.gwt.core.client.GWT.create(GWT.java:97)
    at com.ais.gwt.client.MyCallback.onFailure(MyCallback.java:21)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:237)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    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:213)
    at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Thread.java:679)

Reply all
Reply to author
Forward
0 new messages