Ant Build ArrayIndexOutOfBoundsException в рабочей области Java - PullRequest
0 голосов
/ 06 мая 2019

Я пытаюсь создать веб-приложение с помощью скрипта Ant. Приложение имеет много модулей, и после компиляции нескольких проектов сборка завершается неудачно со следующими журналами ошибок:

[javac] Исключительная ситуация в компиляторе (1.4.2). Пожалуйста, отправьте сообщение об ошибке в Java Developer Connection (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)

1 Ответ

1 голос
/ 08 мая 2019

После двух дней борьбы, наконец, проблема была найдена.Это было вызвано дубликатами .class файлов в JAR.Это очень странно, так как я видел, как задачи Ant копируют дубликат файла .class (с предупреждением в подробном режиме -v) во время упаковки JAR-файлов.Вот фрагмент из файла сценария сборки, который был виновником:

<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

...