当我尝试将Apache Stanbol安装为本地实例时,我收到以下异常:
ERROR] Java heap space -> [Help 1]
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at aQute.lib.osgi.EmbeddedResource.copy(EmbeddedResource.java:62)
at aQute.lib.osgi.EmbeddedResource.collect(EmbeddedResource.java:51)
at aQute.lib.osgi.EmbeddedResource.build(EmbeddedResource.java:33)
at aQute.lib.osgi.EmbeddedResource.build(EmbeddedResource.java:71)
at aQute.lib.osgi.Verifier.getBundleClassPath(Verifier.java:255)
at aQute.lib.osgi.Verifier.<init>(Verifier.java:204)
at aQute.lib.osgi.Builder.doVerify(Builder.java:434)
at aQute.lib.osgi.Builder.build(Builder.java:104)
at org.apache.felix.bundleplugin.BundlePlugin.buildOSGiBundle(BundlePlugin.java:547)
at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:347)
at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:264)
at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:255)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
[ERROR]
[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/OutOfMemoryError
我使用以下命令增加了JVM内存,但我仍然遇到同样的错误。我的RAM是4 GB。
导出MAVEN_OPTS =“ - Xmx3000m -XX:MaxPermSize = 512m”
如何解决并解决此问题?
谢谢,
杰
答案 0 :(得分:0)
要设置的环境变量是MAVEN_OPTS,例如MAVEN_OPTS = -Xmx1024m。仅当您将编译器插件设置为fork javac到新JVM时,pom中的maxmem配置才适用。否则,插件在与Maven相同的VM内部运行,因此在通过MAVEN_OPTS在命令行上传递的内存中运行。
在Windows 7下设置MAVEN_OPTS:
打开一个新的命令窗口并运行mvn。
答案 1 :(得分:0)
如果在构建过程中有大量资源过滤且没有足够的堆空间分配给Maven,则会在OSGI环境中发生这种情况。
如果你指定了这样的资源和过滤器,它应该解决问题......
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/filtered-resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/etc/org.yourcompany.yourproject.cfg</filter>
</filters>
注意:指定了过滤器文件(以.cfg结尾的文件) 如果没有这个,您将在尝试解析资源令牌时收到OutOfMemory错误。因此嵌入式资源阵列复制。
答案 2 :(得分:-1)
增加内存不是OOM错误的解决方案。它可以是暂时的缓解,但不是永久的解决方案。您需要修复导致内存泄漏的代码。
从异常看来,似乎有一些代码复制数组,并且它以递归方式执行,导致堆内存溢出。