java - GWT 错误 : java. lang.RuntimeException: 'com.google.gwt.maps.client.impl.MapImpl' 的延迟绑定(bind)失败

标签 java gwt gwt2

我收到错误...

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-google-apis 的一个已知问题。引用自相关issue :

There is a binary incompatibility introduced in GWT 2.2 which causes problems when linking against binary jars compiled with older GWT distributions.

The workarounds are to use an older version of GWT or to re-compile gwt-maps.jar from source.

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

关于java - GWT 错误 : java. lang.RuntimeException: 'com.google.gwt.maps.client.impl.MapImpl' 的延迟绑定(bind)失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5297745/

相关文章:

java - Hibernate 查询集合中的 ID 返回太多结果

java - 带有可滚动对象的 JDialog

GWT FileUpload - Servlet 选项和处理响应

java - 使用 GWT 和 Spring Security 的条件 UI?

java - 如何自定义自定义 http 错误代码返回的默认 html 文件

java - 如何根据用户输入更新 bean

java - 如何向 GWT ButtonCell 添加点击处理程序?

javascript - ios Cordova javascript 焦点事件永远不会到来

javascript - 合并 GWT 生成的文件

gwt - GWT 2.4 中的拖放