Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.1:jar (attach-javadocs) on

时间:2022-04-09 17:14:13
今天给项目搭建了一个新的开发环境,不知什么原因,eclipse中报了如下错误。在网上找了好久愣是没找到相关解决办法,也有部分网友给了不错的建议如查看java的环境变量配置、重新搭建部署maven等。
都得不到解决办法,最后偶尔看到一个关于eclipse内存设置的文档,觉得有可能关联。就试了试修改了eclipse的内存配置,果然解决了问题。(本文最末端有答案)


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.1:jar (attach-javadocs) on project langpack: MavenReportException: Error while creating archive:
[ERROR] Exit code: 1 - java.lang.StringIndexOutOfBoundsException: String index out of range: 50
[ERROR] at java.lang.String.substring(String.java:1907)
[ERROR] at sun.net.www.ParseUtil.unescape(ParseUtil.java:164)
[ERROR] at sun.net.www.ParseUtil.decode(ParseUtil.java:200)
[ERROR] at sun.misc.URLClassPath$FileLoader.<init>(URLClassPath.java:1016)
[ERROR] at sun.misc.URLClassPath$3.run(URLClassPath.java:357)
[ERROR] at sun.misc.URLClassPath$3.run(URLClassPath.java:352)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at sun.misc.URLClassPath.getLoader(URLClassPath.java:351)
[ERROR] at sun.misc.URLClassPath.getLoader(URLClassPath.java:328)
[ERROR] at sun.misc.URLClassPath.findResource(URLClassPath.java:171)
[ERROR] at java.net.URLClassLoader$2.run(URLClassLoader.java:551)
[ERROR] at java.net.URLClassLoader$2.run(URLClassLoader.java:549)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findResource(URLClassLoader.java:548)
[ERROR] at java.lang.ClassLoader.getResource(ClassLoader.java:1138)
[ERROR] at java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:227)
[ERROR] at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:94)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:87)
[ERROR] at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:275)
[ERROR] at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:247)
[ERROR] at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:126)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.LayoutParser.parseXML(LayoutParser.java:88)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:117)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:186)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:183)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:125)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:83)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:63)
[ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:39)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:280)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:160)
[ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:397)
[ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:167)
[ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:59)
[ERROR] at com.sun.tools.javadoc.Main.main(Main.java:49)
[ERROR] com.sun.tools.doclets.internal.toolkit.util.DocletAbortException
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.LayoutParser.parseXML(LayoutParser.java:95)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:117)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:186)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:183)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:125)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:83)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:63)
[ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:39)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:280)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:160)
[ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:397)
[ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:167)
[ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:59)
[ERROR] at com.sun.tools.javadoc.Main.main(Main.java:49)
[ERROR] com.sun.tools.doclets.internal.toolkit.util.DocletAbortException
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:190)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:183)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:125)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:83)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:63)
[ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:39)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:601)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:280)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:160)
[ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:397)
[ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:167)
[ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:59)
[ERROR] at com.sun.tools.javadoc.Main.main(Main.java:49)
[ERROR] 
[ERROR] Command line was: "D:\Program Files\Java\jdk1.7.0_07\jre\..\bin\javadoc.exe" @options @packages
[ERROR] 
[ERROR] Refer to the generated Javadoc files in 'D:\cmbc\cmbc_20160328\langpack\target\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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :langpack


解决方案是把eclipse安装目录下eclipse.ini的文件中-Xmx设置小一点(我之前设置的是1024M报错之后设置512M就OK了)
至于为什么会出现上述问题可能跟系统的内存有关,因为-Xmx关联的是jvm运行最大占内存数(默认是系统物理内存的1/4)。把自己的物理内存整大点说不定也就解决了上述问题毕竟1024M不算大。