I'm developing a java web application where I'm using mavenlike tool of project managment. Now my trouble is that if i setted jetty for autoscan each 20 second in this way:
<!-- To launch embded jetty server -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven-jetty-plugin.version}</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${project.name}</contextPath>
<extraClasspath>target/classes;../services/target/classes;</extraClasspath>
</webAppConfig>
<scanTargets>
<scanTarget>target/classes</scanTarget>
<scanTarget>../services/target/classes</scanTarget>
</scanTargets>
</configuration>
</plugin>
Jetty starts in a correct way in fact i get:
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 20 seconds.
But at the first scan i get the following error:
ERROR ContextLoader - Context initialization failed
java.lang.OutOfMemoryError: PermGen space
How can I do to fix it?
Update 1
I try to increse a PermGen space from my Eclipse Ide in this way:
but after the first scan i get back the same error.
How can I do to fix it?
Put this under the <configuration>
element: <jvmArgs>-XX:PermSize=256M -XX:MaxPermSize=512M</jvmArgs>
So the Maven plugin will look like this:
<!-- To launch embded jetty server -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven-jetty-plugin.version}</version>
<configuration>
<jvmArgs>-XX:PermSize=256M -XX:MaxPermSize=512M</jvmArgs>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${project.name}</contextPath>
<extraClasspath>target/classes;../services/target/classes;</extraClasspath>
</webAppConfig>
<scanTargets>
<scanTarget>target/classes</scanTarget>
<scanTarget>../services/target/classes</scanTarget>
</scanTargets>
</configuration>
</plugin>
NOTE: if it fails with a message that it can't allocate so much memory use lower numbers.
Have you tried running under JDK8? PermGen has been replaced with MetaSpace and might fix your PermGen issues: http://www.infoq.com/news/2013/03/java-8-permgen-metaspace
Jetty also has some documentation about preventing classloader leaks that might fill up permgen: http://www.eclipse.org/jetty/documentation/current/preventing-memory-leaks.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With