0

我正在尝试使用 Ant 构建脚本构建 Web 应用程序。应用程序有许多模块,编译几个项目后构建失败并显示以下错误日志:

[javac] 编译器(1.4.2)发生异常。在检查 Bug Parade 是否有重复项后,请在 Java 开发人员连接 ( http://java.sun.com/cgi-bin/bugreport.cgi ) 提交一个错误。在报告中包含您的程序和以下诊断。谢谢你。 [javac] java.lang.ArrayIndexOutOfBoundsException:25459

这是一个 Java 4 应用程序。已尝试使用Ant 1.7 和 1.8 版构建它,但都失败并出现相同的错误。

这是完整的堆栈跟踪:

[javac] An exception has occurred in the compiler (1.4.2). Please file a bug at the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
[javac] java.lang.ArrayIndexOutOfBoundsException: 25459
[javac] at com.sun.tools.javac.v8.code.ClassReader.readPool(ClassReader.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.code.ClassReader.readName(ClassReader.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.code.ClassReader.readClassAttrs(ClassReader.java:795)
[javac] at com.sun.tools.javac.v8.code.ClassReader.readClass(ClassReader.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.code.ClassReader.readClassFile(ClassReader.java:963)
[javac] at com.sun.tools.javac.v8.code.ClassReader.fillIn(ClassReader.java:1121)
[javac] at com.sun.tools.javac.v8.code.ClassReader.complete(ClassReader.java:1076)
[javac] at com.sun.tools.javac.v8.code.Symbol.complete(Symbol.java(Inlined Compiled Code))
[javac] at com.sun.tools.javac.v8.code.Symbol$ClassSymbol.complete(Symbol.java(Inlined Compiled Code))
[javac] at com.sun.tools.javac.v8.code.ClassReader.loadClass(ClassReader.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Resolve.loadClass(Resolve.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Resolve.findIdentInPackage(Resolve.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Attr.selectSym(Attr.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Attr.visitSelect(Attr.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.tree.Tree$Select.accept(Tree.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Attr.attribType(Attr.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.visitImport(Enter.java:780)
[javac] at com.sun.tools.javac.v8.tree.Tree$Import.accept(Tree.java:424)
[javac] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.memberEnter(Enter.java(Inlined Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.memberEnter(Enter.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.visitTopLevel(Enter.java:763)
[javac] at com.sun.tools.javac.v8.tree.Tree$TopLevel.accept(Tree.java:407)
[javac] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.memberEnter(Enter.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.comp.Enter$CompleteEnter.complete(Enter.java:865)
[javac] at com.sun.tools.javac.v8.code.Symbol.complete(Symbol.java(Compiled Code))
[javac] at com.sun.tools.javac.v8.code.Symbol$ClassSymbol.complete(Symbol.java:708)
[javac] at com.sun.tools.javac.v8.comp.Enter.complete(Enter.java:618)
[javac] at com.sun.tools.javac.v8.comp.Enter.main(Enter.java:599)
[javac] at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:348)
[javac] at com.sun.tools.javac.v8.Main.compile(Main.java:586)
[javac] at com.sun.tools.javac.Main.compile(Main.java:67)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
[javac] at java.lang.reflect.Method.invoke(Method.java:391)
[javac] at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
[javac] at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1134)
[javac] at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:62)
[javac] at java.lang.reflect.Method.invoke(Method.java:391)
[javac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at org.apache.tools.ant.Target.execute(Target.java:390)
[javac] at org.apache.tools.ant.Target.performTasks(Target.java:411)
[javac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[javac] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
[javac] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[javac] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
[javac] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
[javac] at java.lang.reflect.Method.invoke(Method.java:391)
[javac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at org.apache.tools.ant.Target.execute(Target.java:390)
[javac] at org.apache.tools.ant.Target.performTasks(Target.java:411)
[javac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[javac] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
[javac] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[javac] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
[javac] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
[javac] at java.lang.reflect.Method.invoke(Method.java:391)
[javac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at org.apache.tools.ant.Target.execute(Target.java:390)
[javac] at org.apache.tools.ant.Target.performTasks(Target.java:411)
[javac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[javac] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
[javac] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[javac] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
[javac] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:62)
[javac] at java.lang.reflect.Method.invoke(Method.java:391)
[javac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at org.apache.tools.ant.Target.execute(Target.java:390)
4

1 回答 1

1

经过两天的努力,终于找到了问题。这是由JAR 中的重复 .class文件引起的。这很奇怪,因为我看到 ant 任务在打包 JAR 时复制了重复的 .class 文件(在详细模式 -v 中带有警告)。以下是罪魁祸首构建脚本文件的片段:

<jar destfile="${dir_dest}" manifest="${dir_src}/META-INF/MANIFEST.MF">
    <fileset dir="${dir_dest}" />   
    <fileset dir="${dir_src}" excludes="**/*.java"/> 
</jar>

删除后脚本成功运行:

<fileset dir="${dir_dest}" />

以下链接帮助我解决了这个问题: http ://ant.1045680.n5.nabble.com/corrupt-jar-files-and-javac-td1359404.html

报告相同(或类似)问题但没有答案的其他链接: https ://coderanch.com/t/68624/application-servers/EJB-Complie-failure

https://discourse.igniterealtime.org/t/i-need-to-develop-a-jm-plugin-but-compile-file-is-error/73578/6

于 2019-05-08T16:14:01.517 回答