Eclipse Oxygen和Google Cloud Tools缺少来自Build Path的javax.servlet类

时间:2017-11-10 13:59:55

标签: google-app-engine google-cloud-platform google-plugin-eclipse

我在Eclipse中有一个GAE项目,它一直没有问题。我最近升级到了Google Cloud SDK 179.0.0和Eclipse Oxygen.1a Release(4.7.1a),现在,当我打开项目时,我在javax.servlet.http包中的类上遇到构建路径错误。具体来说,我的项目的构建路径中缺少以下类。

javax.servlet.ServletContext
javax.servlet.http.HttpServlet

如果使用以下命令从控制台启动Eclipse(假设Eclipse安装在/ Applications文件夹中):

cd  /Applications/Eclipse.app/Contents/MacOS
./eclipse

你看终端窗口,你会看到一堆类似于以下的堆栈跟踪:

Nov 10, 2017 9:24:57 AM com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider doResolveClasspathContainer
WARNING: Failed to initialize libraries
org.eclipse.core.runtime.CoreException: Could not resolve artifact com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:776)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:743)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:720)
    at com.google.cloud.tools.eclipse.util.MavenUtils.resolveArtifact(MavenUtils.java:69)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.MavenHelper.resolveArtifact(MavenHelper.java:46)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.M2RepositoryService.resolveArtifact(M2RepositoryService.java:50)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryFileAttachSourceSync(LibraryClasspathContainerResolverService.java:245)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryAttachSourcesSync(LibraryClasspathContainerResolverService.java:106)
    at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.doResolveClasspathContainer(ServletClasspathProvider.java:100)
    at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.resolveClasspathContainer(ServletClasspathProvider.java:79)
    at org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate.resolveClasspathContainerImpl(RuntimeClasspathProviderDelegate.java:135)
    at org.eclipse.jst.server.core.internal.RuntimeClasspathProviderWrapper.resolveClasspathContainerImpl(RuntimeClasspathProviderWrapper.java:155)
    at org.eclipse.jst.server.core.internal.RuntimeClasspathContainer.getClasspathEntries(RuntimeClasspathContainer.java:77)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2693)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
    at org.eclipse.jdt.internal.core.ExternalFolderChange.updateExternalFoldersIfNecessary(ExternalFolderChange.java:39)
    at org.eclipse.jdt.internal.core.ChangeClasspathOperation.classpathChanged(ChangeClasspathOperation.java:59)
    at org.eclipse.jdt.internal.core.SetContainerOperation.executeOperation(SetContainerOperation.java:111)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:795)
    at org.eclipse.jdt.internal.core.JavaModelManager$10.run(JavaModelManager.java:3001)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:3017)
    at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:2038)
    at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:3497)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2687)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
    at org.eclipse.jdt.internal.core.DynamicProjectReferences.getDependentProjects(DynamicProjectReferences.java:34)
    at org.eclipse.core.internal.resources.ProjectDescription.computeDynamicReferencesForProject(ProjectDescription.java:950)
    at org.eclipse.core.internal.resources.ProjectDescription.getAllBuildConfigReferences(ProjectDescription.java:265)
    at org.eclipse.core.internal.resources.ProjectDescription.getAllReferences(ProjectDescription.java:221)
    at org.eclipse.core.internal.resources.Project.getReferencedProjects(Project.java:469)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.buildConnectedComponents(CloseUnrelatedProjectsAction.java:78)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.computeRelated(CloseUnrelatedProjectsAction.java:195)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.getSelectedResources(CloseUnrelatedProjectsAction.java:211)
    at org.eclipse.ui.actions.SelectionListenerAction.selectionIsOfType(SelectionListenerAction.java:240)
    at org.eclipse.ui.actions.CloseResourceAction.updateSelection(CloseResourceAction.java:187)
    at org.eclipse.ui.actions.BaseSelectionListenerAction.selectionChanged(BaseSelectionListenerAction.java:124)
    at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.updateActionBars(ResourceMgmtActionProvider.java:254)
    at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.fillActionBars(ResourceMgmtActionProvider.java:84)
    at org.eclipse.ui.navigator.NavigatorActionService$3.run(NavigatorActionService.java:265)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.navigator.NavigatorActionService.fillActionBars(NavigatorActionService.java:258)
    at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob$1.run(CommonNavigatorManager.java:95)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob.runInUIThread(CommonNavigatorManager.java:89)
    at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:95)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4033)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
    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:653)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
Contains: Missing com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57

安装了179.0版本的Google Cloud SDK后,我现在安装了App Engine 1.9.59而不是1.9.57。

Eclipse构建路径包含以下库:

  • App Engine标准运行时[App Engine标准运行时]
  • EAR图书馆
  • JRE系统库[JavaSE-1.8]
  • TestNG的
  • 网络应用程序库

我在以下Eclipse版本中遇到同样的问题:

  • 4.7.0(Build Id:20170620-1800)
  • 4.7.1a(Build Id:20171005-1200)

以下是我的项目现在的错误列表:

  • 无法将RequestDispatcher解析为类型
  • 项目未构建,因为其构建路径不完整。找不到javax.servlet.ServletContext的类。修复构建路径,然后尝试构建此项目
  • 在Java Build Path中找不到超类“javax.servlet.http.HttpServlet”
  • 无法解析javax.servlet.ServletContext类型。它是从所需的.class文件间接引用的

将新的App Engine Standard Edition项目创建为Maven项目,指定对1.9.57版App Engine API的依赖。

<dependency>
  <groupId>com.google.appengine</groupId>
  <artifactId>appengine-api-1.0-sdk</artifactId>
  <version>1.9.57</version>
  <scope>provided</scope>
</dependency>

在“GoogleCloudPlatform / google-cloud-eclipse”项目下的GitHub上针对此问题创建了问题#2754。

https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2574

<小时/> 版本信息

  • Eclipse Oxygen.1a Release(4.7.1a Build:20171005-1200)
  • Google Cloud Platform for Eclipse 4.5及更高版本1.4.1.201710261936
  • Google Cloud SDK 179.0.0
  • alpha 2017.09.15
  • app-engine-java 1.9.59
  • app-engine-python 1.9.62
  • beta 2017.09.15
  • bq 2.0.27
  • 核心2017.11.06
  • gcd-emulator v1beta3-1.0.0
  • gcloud
  • gsutil 4.28
  • kubectl
  • pubsub-emulator 2017.09.15

1 个答案:

答案 0 :(得分:0)

我不知道问题的确切原因,但重新启动计算机可以解决此错误中报告的问题。在尝试解决此问题的过程中,我确实停止并多次启动Eclipse以解决此问题。我开始了新的终端窗口会议,以解决问题,但这没有用。

完全重启我的机器后,此错误中报告的问题消失了。