在两个Web应用程序之间共享实例时Maven Jetty插件OutOfMemoryError [英] Maven Jetty Plugin OutOfMemoryError When Sharing Instance Between Two Web Apps
问题描述
我正在使用maven jetty插件来运行我的两个Web应用程序。一个Web应用程序是spring mvc UI,另一个是RESTful Web应用程序。当我运行两个单独的mvn jetty时,我能够让两个Web应用程序进行通信:运行实例并分配不同的端口。我已使用下面的maven pom.xml配置使用相同的端口在同一个jetty实例中成功部署。我最终得到一个ava.lang.OutOfMemoryError:PermGen空间错误。对此最好的解决方法是什么?
I'm using the maven jetty plugin to run my two web applications. One web application is spring mvc UI and the other is a RESTful web application. I able to get the two web applications to communicate when I run two separate mvn jetty:run instances and assign different ports. I have successfully deploy both in the same jetty instance using the same port using the below maven pom.xml configuration. I eventually get a ava.lang.OutOfMemoryError: PermGen space error. What is the best workaround for this?
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.6.8.v20121106</version>
<configuration>
<jvmArgs>-Xmx2024m -Xms2024m</jvmArgs>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>../../api/target/main-api.war</war>
<contextPath>/test</contextPath>
</contextHandler>
</contextHandlers>
</configuration>
</plugin>
推荐答案
添加以下jvm参数,如果收到错误则不能分配内存然后尝试使用较小的值(128和256)
Add following jvm argument, if you get error regarding cannot allocate memory then try using lesser value (128 and 256)
-XX:PermSize=256M -XX:MaxPermSize=512M
参考
- What is 'PermSize' in Java?
- -XX:MaxPermSize with or without -XX:PermSize
这篇关于在两个Web应用程序之间共享实例时Maven Jetty插件OutOfMemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!