试着保持教程

时间:2012-12-06 18:06:45

标签: java google-maps gwt

我正在尝试将教程simpleMaps的GWT保留在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>

1 个答案:

答案 0 :(得分:1)

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

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

  1. 查找gwt-map3的来源,并使用GWT 2.5 SDK手动构建
  2. 转换您的项目以使用GWT 2.1 SDK