-1

我正在尝试将 GWT 的教程 simpleMaps 保留在 gwt-maps3 库上,但是当启动应用程序时,会在浏览器上显示下一个错误:

java.lang.reflect.InvocationTargetException
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:601)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ExceptionInInitializerError
at com.google.gwt.maps.client.MapOptions.<init>(MapOptions.java:40)
at com.map.juan.client.SimpleMap.onModuleLoad(SimpleMap.java:18)
... 9 more
Caused by: java.lang.RuntimeException: Deferred binding failed for 'com.google.gwt.maps.client.impl.MapOptionsImpl' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.shared.GWT.create(GWT.java:57)
at com.google.gwt.core.client.GWT.create(GWT.java:85)
at com.google.gwt.maps.client.impl.MapOptionsImpl.<clinit>(MapOptionsImpl.java:31)
... 11 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface com.google.gwt.core.ext.typeinfo.JClassType, but class was expected
at com.google.gwt.jsio.rebind.JSWrapperGenerator.generate(JSWrapperGenerator.java:276)
at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:657)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
... 14 more

我该如何解决?

谢谢

添加了.java

public class SimpleMap implements EntryPoint 
{
private MapWidget mapWidget;

// GWT module entry point method.
public void onModuleLoad() 
{
    final MapOptions options = new MapOptions();
    // Zoom level. Required
    options.setZoom(8);
    // Open a map centered on Cawker City, KS USA. Required
    options.setCenter(new LatLng(39.509, -98.434));
    // Map type. Required.
    options.setMapTypeId(new MapTypeId().getRoadmap());

    // Enable maps drag feature. Disabled by default.
    options.setDraggable(true);
    // Enable and add default navigation control. Disabled by default.
    options.setNavigationControl(true);
    // Enable and add map type control. Disabled by default.
    options.setMapTypeControl(true);
    mapWidget = new MapWidget(options);
    mapWidget.setSize("800px", "600px");

    // Add the map to the HTML host page
    RootPanel.get("mapsTutorial").add(mapWidget);
}

添加了.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-   module.dtd">
<module rename-to='simplemap'>
<!-- Inherit the core Web Toolkit stuff.                        -->
<inherits name='com.google.gwt.user.User'/>

<inherits name='com.google.gwt.user.theme.clean.Clean'/>

<!-- Other module inherits                                      -->
<inherits name='com.google.gwt.maps.Maps' />    
<!-- <script src="http://maps.google.com/maps/api/js?sensor=false"></script> -->
 <script src="http://maps.google.com/maps? gwt=1&amp;file=api&amp;v=2.148" />
<!-- Specify the app entry point class.                         -->
<entry-point class='com.map.juan.client.SimpleMap'/>

<!-- Specify the paths for translatable code                    -->
<source path='client'/>
<source path='shared'/>

</module>
4

1 回答 1

1

好吧,问题是因为 GWT 2.2JClassType被转换为接口而不是抽象类。在您的情况下,您在使用 GWT 2.5 的项目中使用了一些已使用 GWT 2.1 编译的库。这就是您收到此错误的原因。

要解决此问题,您有两种选择:

  1. 查找 gwt-map3 的源代码,并使用 GWT 2.5 SDK 手动构建
  2. 将您的项目转换为使用 GWT 2.1 SDK
于 2012-12-07T14:05:01.303 回答