使用maven构建项目java.nio.BufferOverflowException问题的解决

问题:

在使用maven构建Java开源项目,有时候会遇到BufferOverflowExceptio<wbr></wbr>n异常(异常详细信息见后面)。

是Bug吗?

在sun的网站上有jdk 1.4.2和jdk 1.6.0 的bug报告,其实这个问题在 jdk 1.5.0_10和jdk 1.5.0_11中也有.

http://bugs.sun.com/bugdatabase<wbr></wbr>/view_bug.do?bug_id=6526175

虽然sun不认为这是一个bug,解决建议是增加heap size,就是设置环境变量,增加内存的使用参数值;经过测试,这种解决方法不能有效消除错误的产生。

其他人是如何解决的?

从google中找到在其他的apache的项目中出现过同样的异常,但是都没能解决。

问题产生的原因?

可能原因是由于字符集使用GBK、UTF-8或者UTF-16导致使用多字节存放字符,内存使用增加,堆(heap)的尺寸无法提供程序所需的空间,造成异常。更深入的分析还在进行中。

解决方法:

将操作系统的区域和语言选项中的区域设置为 English 即可!

辅助的方法是在系统环境变量中增加设置: MAVEN_OPTS=-Xmx512m

详细错误信息:

Failure executing javac, but could not parse the error:
编译器 (1.5.0_10) 中出现异常。 如果在 Bug Parade 中没有找到该错误,请在 Java Dev
eloper Connection (http://java.sun.com/webapps<wbr></wbr>/bugreport ) 对该错误进行归档。 请
在报告中附上您的程序和以下诊断信息。谢谢您的合作。
java.nio.BufferOverflowExceptio<wbr></wbr>n
at java.nio.Buffer.nextPutIndex(Buffer.java:419)
at java.nio.HeapCharBuffer.put(HeapCharBuffer.java:145)
at com.sun.tools.javac.parser<wbr></wbr>.Scanner.decode(Scanner.java:405)
at com.sun.tools.javac.parser<wbr></wbr>.Scanner.<init>(Scanner.java:304)
at com.sun.tools.javac.parser<wbr></wbr>.Scanner.<init>(Scanner.java:238)
at com.sun.tools.javac.parser<wbr></wbr>.Scanner$Factory.newScanner(Scanner.java:72
)
at com.sun.tools.javac.main<wbr></wbr>.JavaCompiler.parse(JavaCompiler.java:254)
at com.sun.tools.javac.main<wbr></wbr>.JavaCompiler.parse (JavaCompiler.java:281)
at com.sun.tools.javac.main<wbr></wbr>.JavaCompiler.compile(JavaCompiler.java:399)
at com.sun.tools.javac.main.Main<wbr></wbr>.compile(Main.java:592)
at com.sun.tools.javac.main.Main<wbr></wbr>.compile (Main.java:544)
at com.sun.tools.javac.Main<wbr></wbr>.compile(Main.java:85)
at sun.reflect.NativeMethodAccesso<wbr></wbr>rImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccesso<wbr></wbr>rImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAcc<wbr></wbr>essorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.plexus.compiler<wbr></wbr>.javac.JavacCompiler.compileInP<wbr></wbr>rocess (Jav
acCompiler.java:400)
at org.codehaus.plexus.compiler<wbr></wbr>.javac.JavacCompiler.compile(JavacCompile
r.java:136)
at org.apache.maven.plugin<wbr></wbr>.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java :483)
at org.apache.maven.plugin<wbr></wbr>.CompilerMojo.execute(CompilerMojo.java:111)
at org.apache.maven.plugin<wbr></wbr>.DefaultPluginManager.executeMo<wbr></wbr>jo(DefaultPlugi
nManager.java:412)
at org.apache.maven.lifecycle<wbr></wbr>.DefaultLifecycleExecutor<wbr></wbr>.executeGoals (Defa
ultLifecycleExecutor.java:534)
at org.apache.maven.lifecycle<wbr></wbr>.DefaultLifecycleExecutor<wbr></wbr>.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:475)
at org.apache.maven.lifecycle<wbr></wbr>.DefaultLifecycleExecutor<wbr></wbr>.executeGoal (Defau
ltLifecycleExecutor.java:454)
at org.apache.maven.lifecycle<wbr></wbr>.DefaultLifecycleExecutor<wbr></wbr>.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:306)
at org.apache.maven.lifecycle<wbr></wbr>.DefaultLifecycleExecutor<wbr></wbr>.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:273)
at org.apache.maven.lifecycle<wbr></wbr>.DefaultLifecycleExecutor<wbr></wbr>.execute(DefaultLi
fecycleExecutor.java:140)
at org.apache.maven.DefaultMaven<wbr></wbr>.doExecute(DefaultMaven.java :322)
at org.apache.maven.DefaultMaven<wbr></wbr>.execute(DefaultMaven.java:115)
at org.apache.maven.cli.MavenCli<wbr></wbr>.main(MavenCli.java:256)
at sun.reflect.NativeMethodAccesso<wbr></wbr>rImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccesso<wbr></wbr>rImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAcc<wbr></wbr>essorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:585)
at org.codehaus.classworlds<wbr></wbr>.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds<wbr></wbr>.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds<wbr></wbr>.Launcher.mainWithExitCode (Launcher.java:430)

at org.codehaus.classworlds<wbr></wbr>.Launcher.main(Launcher.java:375)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值