简体   繁体   English

在 GWT 上使用谷歌地图时出现问题

[英]Problem using google Maps on GWT

I am trying to use the latest jar of google-maps-api-v3 on GWT by following this tutorial step by step but when I try to use it in my application, I got this exception:我正在尝试按照本教程一步一步地在 GWT 上使用 google-maps-api-v3 的最新 jar,但是当我尝试在我的应用程序中使用它时,我得到了这个异常:

    Loading modules
   ht.haitidataservices.simplemap.SimpleMap
      Loading inherited module 'com.google.gwt.maps.Maps'
         [ERROR] Unable to find 'com/google/gwt/maps/Maps.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
      [ERROR] Line 5: Unexpected exception while processing element 'inherits'
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:262)
    at com.google.gwt.dev.cfg.ModuleDefSchema$BodySchema.__inherits_begin(ModuleDefSchema.java:495)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.util.xml.HandlerMethod.invokeBegin(HandlerMethod.java:230)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.startElement(ReflectiveParser.java:274)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:331)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$100(ReflectiveParser.java:48)
    at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:402)
    at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:280)
    at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:192)
    at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:308)
    at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:151)
    at com.google.gwt.dev.DevModeBase.loadModule(DevModeBase.java:979)
    at com.google.gwt.dev.DevMode.loadModule(DevMode.java:548)
    at com.google.gwt.dev.DevMode.doStartup(DevMode.java:436)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1045)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804)
    at com.google.gwt.dev.DevMode.main(DevMode.java:309)
      [ERROR] Failure while parsing XML
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.util.xml.DefaultSchema.onHandlerException(DefaultSchema.java:58)
    at com.google.gwt.dev.util.xml.Schema.onHandlerException(Schema.java:66)
    at com.google.gwt.dev.util.xml.Schema.onHandlerException(Schema.java:66)
    at com.google.gwt.dev.util.xml.HandlerMethod.invokeBegin(HandlerMethod.java:240)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.startElement(ReflectiveParser.java:274)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:331)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$100(ReflectiveParser.java:48)
    at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:402)
    at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:280)
    at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:192)
    at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:308)
    at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:151)
    at com.google.gwt.dev.DevModeBase.loadModule(DevModeBase.java:979)
    at com.google.gwt.dev.DevMode.loadModule(DevMode.java:548)
    at com.google.gwt.dev.DevMode.doStartup(DevMode.java:436)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1045)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804)
    at com.google.gwt.dev.DevMode.main(DevMode.java:309)
      [ERROR] Unexpected error while processing XML
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:355)
    at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$100(ReflectiveParser.java:48)
    at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:402)
    at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:280)
    at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:192)
    at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:308)
    at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:151)
    at com.google.gwt.dev.DevModeBase.loadModule(DevModeBase.java:979)
    at com.google.gwt.dev.DevMode.loadModule(DevMode.java:548)
    at com.google.gwt.dev.DevMode.doStartup(DevMode.java:436)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1045)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804)
    at com.google.gwt.dev.DevMode.main(DevMode.java:309)
[ERROR] shell failed in doStartup method

It seems it's a module problem, saying that it cannot find com/google/gwt/maps/Maps.gwt.xml .看来这是一个模块问题,说它找不到com/google/gwt/maps/Maps.gwt.xml I don't understand since I follow the tutorial and I am sure that what I am doing is correct.我不明白,因为我按照教程进行操作,并且我确信我所做的是正确的。 How can I solve this problem?我怎么解决这个问题? Thanks for your help谢谢你的帮助

I am currently developping on JDK 1.6 with Eclipse Indigo on 64-bit Windows 7 system.我目前正在 JDK 1.6 上使用 Eclipse Indigo 在 64 位 Windows 7 系统上进行开发。

[EDIT] For precision, i added the google-maps jar in my application CLASSPATH and added the inherits line in my module file: [编辑] 为了精确起见,我在我的应用程序 CLASSPATH 中添加了 google-maps jar 并在我的模块文件中添加了继承行:

<module rename-to='egliseenquete'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.maps.Maps' />
    ....
   </module>

[EDIT] I added the maps gwt jar on my CLASSPATH now I get this exception: [编辑] 我在我的 CLASSPATH 上添加了地图 gwt jar 现在我得到了这个异常:

 12:27:28.703 [ERROR] [egliseenquete] Unable to load module entry point class ht.haitidataservices.egliseenquete.client.EgliseEnquete (see associated exception for details)

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.client.GWT.create(GWT.java:98)
    at com.google.gwt.maps.client.impl.MapOptionsImpl.&lt;clinit&gt;(MapOptionsImpl.java:31)
    at com.google.gwt.maps.client.MapOptions.&lt;init&gt;(MapOptions.java:40)
    at ht.haitidataservices.egliseenquete.client.EgliseEnquete.buildMap(EgliseEnquete.java:100)
    at ht.haitidataservices.egliseenquete.client.EgliseEnquete.onModuleLoad(EgliseEnquete.java:94)
    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.ModuleSpace.onLoad(ModuleSpace.java:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:193)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Unknown Source)
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.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
    at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
    at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:681)
    at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
    at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:74)
    at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:285)
    at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
    at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
    at com.google.gwt.core.client.GWT.create(GWT.java:98)
    at com.google.gwt.maps.client.impl.MapOptionsImpl.&lt;clinit&gt;(MapOptionsImpl.java:31)
    at com.google.gwt.maps.client.MapOptions.&lt;init&gt;(MapOptions.java:40)
    at ht.haitidataservices.egliseenquete.client.EgliseEnquete.buildMap(EgliseEnquete.java:100)
    at ht.haitidataservices.egliseenquete.client.EgliseEnquete.onModuleLoad(EgliseEnquete.java:94)
    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.ModuleSpace.onLoad(ModuleSpace.java:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:193)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Unknown Source)

How can I achieve this problem?我怎样才能解决这个问题? Thx for help !!!谢谢帮助!!!

I was having a similar problem.我遇到了类似的问题。

I ended up using this tutorial and it worked great.我最终使用了教程,效果很好。 It is using gwt-maps-1.1.1.zip (Release date for this is much more recent for this one) and the latest GWT.它使用的是 gwt-maps-1.1.1.zip(此版本的发布日期要更新得多)和最新的 GWT。

One thing to note, is that if you are looking at both tutorials to make sure you use:需要注意的一件事是,如果您正在查看两个教程以确保您使用:

<inherits name='com.google.gwt.maps.GoogleMaps' />

and not并不是

<inherits name='com.google.gwt.maps.Maps' />

as they have changed the file name in the com.google.gwt.map package of the jar file. as they have changed the file name in the com.google.gwt.map package of the jar file.

I suspect that if you check the filename in the com.google.gwt.map package of the map jar file, that the file name you were using to inherit is off. I suspect that if you check the filename in the com.google.gwt.map package of the map jar file, that the file name you were using to inherit is off. Then changing that line to what I suggested should fix it.然后将该行更改为我建议的应该修复它。

Hopefully this helps!希望这会有所帮助!

Cheers干杯

After looking inside of the jar file, I noticed that the path inheritance is incorrect for the xml file.在查看 jar 文件内部后,我注意到 inheritance 文件的路径 xml 不正确。

<inherits name='com.google.gwt.maps.GoogleMaps' /> --Is wrong path <inherits name='com.google.gwt.maps.GoogleMaps' /> --路径错误

<inherits name='com.google.maps.gwt.GoogleMaps' /> --Is correct path <inherits name='com.google.maps.gwt.GoogleMaps' /> --是正确的路径

Many hours wasted figuring this out, but this is the solution.浪费了很多时间来解决这个问题,但这是解决方案。 Google made a mistake on their tutorial in this respect.在这方面,谷歌在他们的教程中犯了一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM