简体   繁体   中英

Cannot Run Ant Build in Eclipse

My ant build stopped working sometime recently. I don't know exactly when, since I only do ant builds occasionally in this project. 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:

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

I checked Eclipse's log and I get this error:

!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. I tried upgrading to Eclipse 2020-09 to fix the problem, but no luck.

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

The release file in that java folder says:

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.

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). 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).

I got a similar error after upgrading Eclipse to 2022-03. Ant would not run but showed no errors. Then I noticed the java.net.SocketException: Socket closed error in the workspace logs.

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. Since I could not fix the issue I simply downgraded Eclipse to 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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