1

跑步时总是有StringIndexOutOfBoundsException问题mvn javadoc:javadoc。有人知道这个错误吗?以下是完整的堆栈跟踪:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Java Tool 0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-javadoc-plugin:2.9:javadoc (default-cli) @ osgl-tool >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ osgl-tool ---
[INFO]
[INFO] <<< maven-javadoc-plugin:2.9:javadoc (default-cli) @ osgl-tool <<<
[INFO]
[INFO] --- maven-javadoc-plugin:2.9:javadoc (default-cli) @ osgl-tool ---
[INFO]
Loading source files for package org.osgl.exception...
Loading source files for package org.osgl.util.algo...
Loading source files for package org.osgl.util...
Loading source files for package org.osgl.web.util...
Loading source files for package org.osgl...
Constructing Javadoc information...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.890s
[INFO] Finished at: Tue Feb 18 21:05:48 EST 2014
[INFO] Final Memory: 10M/242M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9:javadoc (default-cli) on project osgl-tool: An error has occurred in JavaDocs report generation:
[ERROR] Exit code: 1 - java.lang.StringIndexOutOfBoundsException: String index out of range: -22
[ERROR] at java.lang.String.substring(String.java:1937)
[ERROR] at java.lang.String.substring(String.java:1904)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.simpleBinaryName(ClassReader.java:958)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.readEnclosingMethodAttr(ClassReader.java:930)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.readMemberAttr(ClassReader.java:909)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.readClassAttr(ClassReader.java:1053)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.readClassAttrs(ClassReader.java:1067)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1560)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:1658)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1845)
[ERROR] at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777)
[ERROR] at com.sun.tools.javac.code.Symbol.complete(Symbol.java:384)
[ERROR] at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:766)
[ERROR] at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:698)
[ERROR] at com.sun.tools.javadoc.ClassDocImpl.getFlags(ClassDocImpl.java:103)
[ERROR] at com.sun.tools.javadoc.ClassDocImpl.isAnnotationType(ClassDocImpl.java:114)
[ERROR] at com.sun.tools.javadoc.DocEnv.isAnnotationType(DocEnv.java:572)
[ERROR] at com.sun.tools.javadoc.DocEnv.getClassDoc(DocEnv.java:544)
[ERROR] at com.sun.tools.javadoc.PackageDocImpl.getClasses(PackageDocImpl.java:154)
[ERROR] at com.sun.tools.javadoc.PackageDocImpl.addAllClassesTo(PackageDocImpl.java:170)
[ERROR] at com.sun.tools.javadoc.RootDocImpl.classes(RootDocImpl.java:178)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:96)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42)
[ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143)
[ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
[ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:128)
[ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:41)
[ERROR] at com.sun.tools.javadoc.Main.main(Main.java:31)
[ERROR]
[ERROR] Command line was: R:\jdk\jre\..\bin\javadoc.exe @options @packages
[ERROR]
[ERROR] Refer to the generated Javadoc files in 'c:\p\java-tool\target\site\apidocs' dir.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

笔记

  1. 是的,我正在使用 eclipse 编译器
  2. 使用 Eclipse 编译器而不是 javac 导致 javadoc 崩溃的问题的答案无济于事
  3. 现在我切换到java编译器,但它仍然不起作用
  4. 这是一个在其上运行 javadoc 时将失败的单个 java 文件(可以编译):https ://github.com/greenlaw110/java-tool/blob/master/src/main/java/org/osgl/ _.java
  5. 具有循环依赖关系的 pom.xml 问题与此问题无关在 Aleksandr 的回答之后删除循环依赖项确实使项目能够构建,甚至能够使用“mvn package -Pdist”构建,但它并不能解决 javadoc 问题。您可以构建和生成 javadoc 的原因是我已经删除了带有<excludePackageNames>org.osgl:org.osgl.util</excludePackageNames>. 尝试将该行从 pom.xml 中取出并mvn clean package -Pdist再次运行以重现 javadoc 问题
  6. 我选择作为underscore.js项目_之后的类名。它用于将一些常见的实用程序聚合到一个类似元的命名空间中。对于不喜欢的人,只需使用替换,因为他们互相别名Osgl_
  7. 在我将项目克隆到数字海洋上的 linux 盒子中之后,它确实取得了成功,这真的很奇怪。我的 Windows 开发机器一定有问题!
  8. 问题解决了!删除循环依赖确实解决了这个问题。我的猜测是循环依赖带回了旧的 osgl-tool pom.xml 版本,它使用 eclipse 编译代码并与 javadoc 冲突
4

2 回答 2

2

您的问题出在您的 pom.xml 文件中。您正在声明org.osgl:osgl-storage具有依赖关系的依赖项org.osgl:osgl-tool- 您正在尝试构建的同一项目,但版本不同。排除这种传递依赖,它应该可以工作。

<dependency>
    <groupId>org.osgl</groupId>
    <artifactId>osgl-storage</artifactId>
    <version>0.3-SNAPSHOT</version>
    <scope>provided</scope>
    <exclusions>
        <exclusion>
            <groupId>org.osgl</groupId>
            <artifactId>osgl-tool</artifactId>
        </exclusion>
    </exclusions>
</dependency> 
于 2015-02-27T11:36:10.337 回答
1

如果你这样做mvn dependency:tree,你会看到 org.osgl:osgl-storage:jar:0.3-SNAPSHOT 也将 org.osgl:osgl-tool:jar:0.3-SNAPSHOT 作为依赖项,这将与你自己的版本冲突同样的神器。

[INFO] org.osgl:osgl-tool:jar:0.4.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.10:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- commons-codec:commons-codec:jar:1.8:compile
[INFO] +- com.carrotsearch:junit-benchmarks:jar:0.7.2:test
[INFO] \- org.osgl:osgl-storage:jar:0.3-SNAPSHOT:provided
[INFO]    +- org.osgl:osgl-tool:jar:0.3-SNAPSHOT:provided
[INFO]    \- org.osgl:osgl-logging:jar:0.2:provided

你需要做的就是告诉 Maven 排除这个传递依赖:

<dependency>
  <groupId>org.osgl</groupId>
  <artifactId>osgl-storage</artifactId>
  <version>0.3-SNAPSHOT</version>
  <scope>provided</scope>
  <exclusions>
    <exclusion>
      <groupId>org.osgl</groupId>
      <artifactId>osgl-tool</artifactId>
    </exclusion>
  </exclusions>
</dependency>

发生的事情是您同时拥有同一工件的两个版本(您的 0.4.1-SNAPSHOT 和另一个 0.3-SNAPSHOT 版本)。上面的解决方案不包括 org.osgl:osgl-storage:jar:0.3-SNAPSHOT 传递的 0.3-SNAPSHOT 版本。


您还通过使 org.osgl:osgl-tool 依赖于 org.osgl:osgl-storage 来创建循环依赖,因为 org.osgl:osgl-storage 最初依赖于 org.osgl:osgl-tool。

org.osgl:osgl-storage <──┐ ... you added this dependency
     │                   │
     └──> org.osgl:osgl-tool

您的org.osgl.util.IO班级是依赖于org.osgl.storage.ISObjectand的班级org.osgl.storage.impl.SObject。如果您不希望出现更多问题,则应避免循环依赖。


编辑:关于_课程,它有一个有效的名称。但是,如果使用这样的名称来避免重复长类名,例如在您的示例中:

void foo(_.Func2<Integer, String> f) {
    F2<Integer, String> newF = _.f2(f);
    ...
}

那么你应该考虑重命名类并使用静态导入

import static org.osgl.Osgl.*; // Osgl instead of _

void foo(Func2<Integer, String> f) { // Func2 statically imported
    F2<Integer, String> newF = f2(f); // f2 statically imported
    ...
}
于 2015-02-27T12:11:41.043 回答