Problems with GWT-Pratform PlaceManager + Gin
I've trying to do something with GWT-Platform, but, following the examples in this page: http://code.google.com/p/gwt-platform/wiki/GettingStarted?tm=6 simple doesn't work.
I got the following error:
java.lang.AssertionError: Internal error, PlaceRequest passed to updateHistory doesn't match the tail of the place hierarchy. at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.updateHistory(PlaceManagerImpl.java:489) at com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract$3$1.execute(ProxyPlaceAbstract.java:208) at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50) at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228) at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:388) at com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78) at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138) 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.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.BrowserChannelSe开发者_如何学编程rver.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.GeneratedMethodAccessor29.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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(Unknown Source)
when I try to make a PlaceRequest.
I guess it occurs because PlaceManager is injected, and, someway, it aren't as singleton, but, following the wiki (http://code.google.com/p/gwt-platform/wiki/GettingStarted?tm=6#Binding_everything_together):
Installing DefaultModule saves you from having to perform all the following bindings: bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class); bind(RootPresenter.class).asEagerSingleton(); bind(PlaceManager.class).to(MyPlaceManager.class).in(Singleton.class); bind(GoogleAnalytics.class).to(GoogleAnalyticsImpl.class).in(Singleton.class);
place manager already has to be a singleton... but, it simply dont work.
Someone has this issue?
Having just had this problem with gwtp 0.6, I found a solution for my problem.
The problem turned out to be that I bound my implementation of PlaceManager in the ClientModule class:
protected void configure() {
// Singletons
install(new DefaultModule(ClientPlaceManager.class));
...
and then automatically bound my same implementation in the presenter constructor
private ClientPlaceManager placeManager ; //wrong - should be the interface
@Inject
public FrameworkLayoutPresenter(final EventBus eventBus, final MyView view, final MyProxy proxy,
final ClientPlaceManager placeManager) //wrong - should be the interface
{
super(eventBus, view, proxy);
this.placeManager = placeManager ;
...
But I should have bound the interface PlaceManager
private PlaceManager placeManager ;
@Inject
public FrameworkLayoutPresenter(final EventBus eventBus, final MyView view, final MyProxy proxy,
final PlaceManager placeManager)
{
super(eventBus, view, proxy);
this.placeManager = placeManager ;
...
Every time I get this exception, it's because the PlaceRequest I pass to updateHistory doesn't have the same NameToken as the current place, which is not legal.
What are you trying to do exactly ?
In case you are using GTWP 0.6 you could use the DefaultModule in this way:
public class ClientModule extends AbstractPresenterModule {
@Override
protected void configure() {
install(new DefaultModule(MyPlaceManager.class));
}
The DefaultModule takes care of Binding EventBus, TokenFormatter, RootPresenter, PlaceManager and GoogleAnalytics.
精彩评论