【问题标题】:GWT ERROR: java.lang.RuntimeException: Deferred binding failed for 'com.google.gwt.maps.client.impl.MapImpl'GWT 错误:java.lang.RuntimeException:“com.google.gwt.maps.client.impl.MapImpl”的延迟绑定失败
【发布时间】:2012-07-03 02:40:09
【问题描述】:

我收到了错误...

java.lang.RuntimeException: Deferred binding failed for 'com.google.gwt.maps.client.impl.MapImpl' (did you forget to inherit a
required module?).......Caused by: java.lang.IncompatibleClassChangeError: Found interface
com.google.gwt.core.ext.typeinfo.JClassType, but class was expected.....

我已将 gwt-maps.jar 包含在 Java 构建路径中,并将以下内容添加到我的 .gwt.xml 文件中:

inherits name="com.google.gwt.maps.GoogleMaps" and <br>
script src="http://maps.google.com/maps?gwt=1&amp;file=api&amp;v=2&amp;sensor=false" 

我的源代码如下。

package com.mymaps.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.maps.client.InfoWindow;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.LargeMapControl;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.Marker;
//import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.RootPanel;

public class GWTMaps implements EntryPoint
{
    private MapWidget mapdd;

    public void onModuleLoad()
    {
        LatLng somewhereInTexas = LatLng.newInstance(30.000, -97.000);

        mapdd = new MapWidget(somewhereInTexas, 2);
        //map = new MapWidget();
        mapdd.setSize("500px", "500px");
        mapdd.addControl(new LargeMapControl());

        //final Marker marker = new Marker(somewhereInTexas);
        //mapdd.addOverlay(marker);

        final InfoWindow infoWin = mapdd.getInfoWindow();
        infoWin.open(mapdd.getCenter(), new InfoWindowContent("Deep in Texas..."));

        /*Timer t = new Timer()
        {
            public void run()
            {
                LatLng newAddress = LatLng.newInstance(18.000, 10.000);
                infoWin.close();
                marker.setVisible(false);
                marker.setLatLng(newAddress);
                marker.setVisible(true);
                map.getInfoWindow().open(newAddress, new InfoWindowContent("Somewhere in Africa..."));
                map.panTo(newAddress);
            }
        };

        t.schedule(6000);*/

        RootPanel.get("mapsTutorial").add(mapdd);
    }
}

【问题讨论】:

  • 您是否尝试在没有互联网连接的情况下运行此代码?
  • 您可以尝试切换回 GWT 2.1.1。 GWT 2.2 发生了重大变化,例如 GIN 中也出现了类似的问题。或者,您可以等待使用 2.2 重新编译的文件。

标签: java gwt gwt2


【解决方案1】:

这是 gwt-google-apis 的一个已知问题。引用相关issue

存在二进制不兼容 在 GWT 2.2 中引入,导致 链接二进制文件时的问题 使用旧 GWT 编译的 jar 分布。

解决方法是使用较旧的 GWT 版本或重新编译 gwt-maps.jar 来自源代码。

或者,您也许可以使用评论者甚至the following method provided by Matt Mastracci提供的罐子之一

【讨论】:

    猜你喜欢
    • 2013-08-09
    • 2014-12-17
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 2014-09-11
    相关资源
    最近更新 更多