gpt4 book ai didi

GWT:在现有 web 应用程序中创建新的 GWT 模块,或作为独立实体

转载 作者:行者123 更新时间:2023-12-02 03:04:24 26 4
gpt4 key购买 nike

我使用 Eclipse GWT 插件创建了一个示例 GWT 网络应用程序,它运行完美。

但是当我尝试添加一个新模块时,

  1. 右键单击我的 webapp 项目,
  2. 选择 新 |其他... | GWT 类 |模块选项;和
  3. 单击向导上的下一步按钮

没有任何反应 - 向导继续保持在同一页面上!

接下来,我复制粘贴了我的工作 web 应用程序的包/目录结构,并手动对 NewModule.gwt.xml 及其内容进行了适当的更改;我还适本地更改了 Java 类名,并刷新了 Eclipse 项目。

但是,现在,当我在项目上运行 GWT Compile 时(通过在 Eclipse 中右键单击项目),它只编译原始的 webapp,完全忽略我的 NewModule我在文件系统上手动创建的模块。

问题:

  1. 我做错了什么?

  2. 是否有命令行方法可以简化在现有网络应用中创建新模块的过程,或者理想情况下,将其创建为独立实体?

我在 Ubuntu 16.04 上使用 GWT 2.8.0 和 Eclipse Neon。也尝试过 GWT 2.7.0,具有与上述相同的行为。

最佳答案

我可以重现这个。值得庆幸的是,记录了一个事件,这将为我们提供一些想法:

Plug-in:   org.eclipse.ui
Serverity: Error
Message: Unhandled event loop exception

java.lang.ClassCastException: org.eclipse.jdt.internal.core.JarEntryFile cannot be cast to org.eclipse.core.resources.IFile
at com.google.gwt.eclipse.core.modules.AbstractModule.getShortName(AbstractModule.java:294)
at com.google.gwt.eclipse.core.modules.AbstractModule.getQualifiedName(AbstractModule.java:272)
at com.google.gwt.eclipse.core.modules.ModuleJarResource.getQualifiedName(ModuleJarResource.java:1)
at com.google.gwt.eclipse.core.modules.AbstractModule.getSimpleName(AbstractModule.java:342)
at com.google.gwt.eclipse.core.modules.ModuleJarResource.getSimpleName(ModuleJarResource.java:1)
at com.google.gwt.eclipse.core.modules.ModuleUtils$3.visit(ModuleUtils.java:220)
at com.google.gwt.eclipse.core.modules.ModuleUtils$3.visit(ModuleUtils.java:1)
at com.google.gwt.eclipse.core.modules.ModuleUtils.visitFragments(ModuleUtils.java:338)
at com.google.gwt.eclipse.core.modules.ModuleUtils.findModule(ModuleUtils.java:212)
at com.google.gwt.eclipse.core.wizards.NewModuleWizardPage.addCommonGWTModulesAsDefaultInherits(NewModuleWizardPage.java:367)
at com.google.gwt.eclipse.core.wizards.NewModuleWizardPage.moduleContainerChanged(NewModuleWizardPage.java:496)
at com.google.gwt.eclipse.core.wizards.NewModuleWizardPage.doFieldChange(NewModuleWizardPage.java:291)
at com.google.gwt.eclipse.core.wizards.NewModuleWizardPage.handleFieldChanged(NewModuleWizardPage.java:322)
at org.eclipse.jdt.ui.wizards.NewContainerWizardPage.containerDialogFieldChanged(NewContainerWizardPage.java:319)
at org.eclipse.jdt.ui.wizards.NewContainerWizardPage.access$1(NewContainerWizardPage.java:314)
at org.eclipse.jdt.ui.wizards.NewContainerWizardPage$ContainerFieldAdapter.dialogFieldChanged(NewContainerWizardPage.java:300)
at org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField.dialogFieldChanged(DialogField.java:75)
at org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField.setText(StringDialogField.java:180)
at org.eclipse.jdt.ui.wizards.NewContainerWizardPage.setPackageFragmentRoot(NewContainerWizardPage.java:470)
at org.eclipse.jdt.ui.wizards.NewContainerWizardPage.initContainerPage(NewContainerWizardPage.java:163)
at com.google.gwt.eclipse.core.wizards.NewModuleWizardPage.initModulePage(NewModuleWizardPage.java:328)
at com.google.gwt.eclipse.core.wizards.NewModuleWizard.addPages(NewModuleWizard.java:55)
at org.eclipse.jface.wizard.WizardSelectionPage.getNextPage(WizardSelectionPage.java:116)
at org.eclipse.ui.internal.dialogs.WorkbenchWizardSelectionPage.getNextPage(WorkbenchWizardSelectionPage.java:98)
at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:869)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:419)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5219)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4553)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4143)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
at org.eclipse.jface.window.Window.open(Window.java:794)
at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:269)
at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:264)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:488)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:353)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:155)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:397)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5219)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4553)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4143)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)

其次是:

Session Data:

eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_112
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product --launcher.GTK_version 2
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product --launcher.GTK_version 2

This is a continuation of log file /home/user/workspace/.metadata/.bak_0.log
Created Time: 2017-05-02 11:19:21.409

在我的例子中,.bak_0.log 中没有什么有趣/新的东西。我已将其报告给 Eclipse 并记录了问题 354gwt-eclipse-plugin

编辑:当然这不能回答您真正的问题,我也会看看是否可以提供帮助。

编辑 2:

由于您手动添加了模块,我假设 IDE 集成不知道它。右键单击您的项目,转到 GWT,然后从折叠中选择设置而不是编译。您是否看到对话框中列出了您的新模块?如果没有,请添加它,然后查看 GWT Compile 是否开始为您工作。

关于命令行,请引用 webAppCreator documentation .

编辑 3:

好的,现在我无法重现您的行为。我重新开始演示代码,然后复制它,这样我在同一个项目中就有了 2 个模块。它们不相互继承或继承任何东西——scratch reference scratch/scratch2 references scratch2。我没有创建另一个 html 文件来引用第二个模块。所以这是我的设置:

./src/scratch/server/GreetingServiceImpl.java
./src/scratch/shared/FieldVerifier.java
./src/scratch/client/Scratch_gwt.java
./src/scratch/client/GreetingService.java
./src/scratch/client/GreetingServiceAsync.java
./src/scratch/Scratch_gwt.gwt.xml

./src/scratch2/server/GreetingService2Impl.java
./src/scratch2/shared/FieldVerifier2.java
./src/scratch2/client/GreetingService2Async.java
./src/scratch2/client/Scratch2_gwt.java
./src/scratch2/client/GreetingService2.java
./src/scratch2/Scratch2_gwt.gwt.xml

我不知道它是否相关(有点怀疑),但我也修改了我的 web.xml:

  <servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>scratch.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>greetServlet2</servlet-name>
<servlet-class>scratch2.server.GreetingService2Impl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/scratch_gwt/greet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>greetServlet2</servlet-name>
<url-pattern>/scratch_gwt/greet2</url-pattern>
</servlet-mapping>

当我右键单击我的 scratch-gwt 项目并转到 GWT |编译,我有:

Project: scratch-gwt
Log level: Info
Ouput style: Obfuscated
Entry Point Modules
Scratch_gwt - scratch
Scratch2_gwt - scratch2

我确实必须在此处添加 Scratch2_gwt 入口点。我的编译输出:

Compiling module scratch.Scratch_gwt
Compiling 5 permutations
Compiling permutation 0...
Compiling permutation 1...
Compiling permutation 2...
Compiling permutation 3...
Compiling permutation 4...
Compile of permutations succeeded
Compilation succeeded -- 11.274s
Linking into /home/user/workspace/scratch-gwt/war/scratch_gwt
Link succeeded
Linking succeeded -- 0.180s
Compiling module scratch2.Scratch2_gwt
Compiling 5 permutations
Compiling permutation 0...
Compiling permutation 1...
Compiling permutation 2...
Compiling permutation 3...
Compiling permutation 4...
Compile of permutations succeeded
Compilation succeeded -- 7.821s
Linking into /home/user/workspace/scratch-gwt/war/scratch2_gwt
Link succeeded
Linking succeeded -- 0.109s

所以,我只能说,确实可以做到这一点。重新验证您的编译设置并从头开始一个新项目再试一次或发布您的一些配置。

关于GWT:在现有 web 应用程序中创建新的 GWT 模块,或作为独立实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43751069/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com