简体   繁体   English

无法运行 Ant 内置 Eclipse

[英]Cannot Run Ant Build in Eclipse

My ant build stopped working sometime recently.我的 ant 构建最近某个时候停止工作。 I don't know exactly when, since I only do ant builds occasionally in this project.我不知道确切的时间,因为我在这个项目中偶尔只做 ant 次构建。 I get the following popup:我收到以下弹出窗口:

在此处输入图像描述

The error is only for this project.该错误仅针对此项目。 I can run a build from another project no problem.我可以从另一个项目运行构建没问题。

The build.xml file can be extremely simple, and still cause the error: build.xml 文件可能非常简单,但仍然会导致错误:

<project basedir=".">
    <target name="init">
    </target>
</project>

I checked Eclipse's log and I get this error:我检查了 Eclipse 的日志,我得到了这个错误:

!SESSION 2020-10-15 04:24:23.311 -----------------------------------------------
eclipse.buildId=4.17.0.I20200902-1800
java.version=13.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.jface 2 0 2020-10-15 04:24:25.323
!MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2020-10-15 04:24:25.323
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
  ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
    Open a type in a Java editor,
    Category(org.eclipse.ui.category.navigate,Navigate,null,true),
    org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@5f67181f,
    ,,true),null),
  org.eclipse.ui.defaultAcceleratorConfiguration,
  org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
  ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
    ,
    Category(org.eclipse.lsp4e.category,Language Servers,null,true),
    org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@1169fdfd,
    ,,true),null),
  org.eclipse.ui.defaultAcceleratorConfiguration,
  org.eclipse.ui.contexts.window,,,system)

!ENTRY org.eclipse.e4.ui.workbench 4 0 2020-10-15 04:24:27.543
!MESSAGE Unable to retrieve the bundle from the URI: bundleclass://org.eclipse.recommenders.news.rcp/org.eclipse.recommenders.internal.news.rcp.toolbar.NewsToolControl

!ENTRY org.eclipse.egit.ui 2 0 2020-10-15 04:24:28.090
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Joshua'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

    !ENTRY org.eclipse.ant.launching 4 120 2020-10-15 04:24:37.887
    !MESSAGE Error logged from Ant UI: 
    !STACK 0
    java.net.SocketException: Socket closed
      at java.base/sun.nio.ch.NioSocketImpl.endAccept(NioSocketImpl.java:689)
      at java.base/sun.nio.ch.NioSocketImpl.accept(NioSocketImpl.java:762)
      at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:662)
      at java.base/java.net.ServerSocket.platformImplAccept(ServerSocket.java:628)
      at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:604)
      at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:561)
      at java.base/java.net.ServerSocket.accept(ServerSocket.java:518)
      at org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener$ServerConnection.run(RemoteAntBuildListener.java:91)

    !ENTRY org.eclipse.core.jobs 4 2 2020-10-15 04:24:37.888
    !MESSAGE An internal error occurred during: "Launching Hypnos build.xml".
    !STACK 0
    java.lang.NullPointerException
      at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getBootpathExt(AbstractJavaLaunchConfigurationDelegate.java:364)
      at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getVMSpecificAttributesMap(AbstractJavaLaunchConfigurationDelegate.java:679)
      at org.eclipse.jdt.launching.JavaLaunchDelegate.getVMRunnerConfiguration(JavaLaunchDelegate.java:92)
      at org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:160)
      at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.runInSeparateVM(AntLaunchDelegate.java:580)
      at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.launch(AntLaunchDelegate.java:251)
      at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:807)
      at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:718)
      at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1021)
      at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1224)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

I was using Eclipse 2020-06.我使用的是 Eclipse 2020-06。 I tried upgrading to Eclipse 2020-09 to fix the problem, but no luck.我尝试升级到 Eclipse 2020-09 来解决问题,但没有成功。

JVM according to eclipse is eclipse.vm=C:\java\jdk-13.0.1\bin\server\jvm.dll JVM 根据 eclipse 是eclipse.vm=C:\java\jdk-13.0.1\bin\server\jvm.dll

The release file in that java folder says:该 java 文件夹中的release文件说:

BUILD_TYPE="commercial"
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION="13.0.1"
JAVA_VERSION_DATE="2019-10-15"
MODULES="java.base java.compiler java.datatransfer java.xml java.prefs java.desktop java.instrument java.logging java.management java.security.sasl java.naming java.rmi java.management.rmi java.net.http java.scripting java.security.jgss java.transaction.xa java.sql java.sql.rowset java.xml.crypto java.se java.smartcardio jdk.accessibility jdk.internal.vm.ci jdk.management jdk.unsupported jdk.internal.vm.compiler jdk.aot jdk.internal.jvmstat jdk.attach jdk.charsets jdk.compiler jdk.crypto.ec jdk.crypto.cryptoki jdk.crypto.mscapi jdk.dynalink jdk.internal.ed jdk.editpad jdk.hotspot.agent jdk.httpserver jdk.internal.le jdk.internal.opt jdk.internal.vm.compiler.management jdk.jartool jdk.javadoc jdk.jcmd jdk.management.agent jdk.jconsole jdk.jdeps jdk.jdwp.agent jdk.jdi jdk.jfr jdk.jlink jdk.jshell jdk.jsobject jdk.jstatd jdk.localedata jdk.management.jfr jdk.naming.dns jdk.naming.rmi jdk.net jdk.pack jdk.rmic jdk.scripting.nashorn jdk.scripting.nashorn.shell jdk.sctp jdk.security.auth jdk.security.jgss jdk.unsupported.desktop jdk.xml.dom jdk.zipfs"
OS_ARCH="x86_64"
OS_NAME="Windows"
SOURCE=".:hg:b06ae01c3eea open:hg:8d03d066c4e8"

Any idea how to address this?知道如何解决这个问题吗?

This seems to be related to the Java used to run the Ant script.这似乎与用于运行 Ant 脚本的 Java 有关。

In the run configuration , in the JRE tab , make sure a JRE/JDK is selected (for an existing Ant run configuration it can happen that the previously selected JRE/JDK is lost due to changes in the preferences Java > Installed JREs or when updating Java).运行配置JRE选项卡中确保选择了 JRE/JDK (对于现有的 Ant 运行配置,可能会由于首选项Java > 已安装 JRE 的更改或更新时丢失先前选择的 JRE/JDK爪哇)。 If a JRE/JDK is already selected, try another JRE/JDK setting here (if there are VM arguments specify, try it without them, since they might be illegal for the chosen VM).如果已经选择了 JRE/JDK,请在此处尝试另一个 JRE/JDK 设置(如果指定了 VM 参数,请在没有它​​们的情况下尝试,因为它们对于所选的 VM 可能是非法的)。

I got a similar error after upgrading Eclipse to 2022-03. Eclipse升级到2022-03后出现类似错误。 Ant would not run but showed no errors. Ant 不会运行但没有显示错误。 Then I noticed the java.net.SocketException: Socket closed error in the workspace logs.然后我注意到工作区日志中的java.net.SocketException: Socket closed错误。

Changing the JRE as suggested by the other answer fixed only if I used a recent Java version but I needed to use JDK 1.8.仅当我使用最新的 Java 版本但我需要使用 JDK 1.8 时,才按照其他答案的建议更改 JRE。 Since I could not fix the issue I simply downgraded Eclipse to 2021-12.由于无法解决问题,我只是将 Eclipse 降级为 2021-12。

Apparently at least Java 11 will be needed to run Ant in future releases: https://bugs.eclipse.org/bugs/show_bug.cgi?id=579317显然,在未来的版本中至少需要 Java 11 才能运行 Ant: https://bugs.eclipse.org/bugs/show_bug.cgi?id=579317

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

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