Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Jetty Plugin OutOfMemoryError When Sharing Instance Between Two Web Apps

Tags:

java

maven

jetty

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>
like image 467
c12 Avatar asked Dec 11 '22 11:12

c12


1 Answers

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

Reference

  • What is 'PermSize' in Java?
  • -XX:MaxPermSize with or without -XX:PermSize
like image 163
Snehal Patel Avatar answered Dec 31 '22 14:12

Snehal Patel