Java7
Posts tagged jbossas
JBoss AS Redeployment giving java.lang.OutOfMemoryError: PermGen space
Apr 1st
I have been using Jboss As 6 a lot lately and it seems that with the new edition of application server from JBoss, it quite often runs into PermGen space issue. To rectify the problem each time, i had to bring down the development server only to bring it up again. It becomes quite haphazard and tedious especially with a slower machine.
A search on Google found some great articles, but the comments left behind by this particular user nailed it (Raghav http://blog.yannis-lionis.gr/?p=8). There were even some silly suggestions like switching to JRockit. Well ignore those.
PermGen space out of memory error when redeploying a JSF 2.0 web application through Maven Cargo plugin
To minimize this, one has to effectively “optimize” the JVM settings which JBoss runs on.
Step 1: Locate and open up run.conf
run.conf is usually found in the bin folder of your application server.
Location of my run.conf file
It is recommended that you modify the settings of the JVM through this file, and not through the .bat itself unless you have specific requirements.
Sample run.conf file
Step 2: Locate and change out the settings below the line that says “rem # JVM memory allocation pool parameters”
Original content
rem # JVM memory allocation pool parameters
set ...(deleted for simplicity)
Change it to:
rem # JVM memory allocation pool parameters
set "JAVA_OPTS=-Xms680m -Xmx680m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled"
Complete!
You now need only to restart your server to see the effects.
bash-3.2$ Calling C:\c\server\jbossas-vms\jboss-6.0.0.Final\bin\run.conf.bat
===============================================================================
JBoss Bootstrap Environment
JBOSS_HOME: C:\c\server\jbossas-vms\jboss-6.0.0.Final
JAVA: C:\Program Files\Java\jdk1.6.0_22\bin\java
JAVA_OPTS: -Dprogram.name=run.bat -Xms680m -Xmx680m -XX:PermSize=245m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -server
CLASSPATH: C:\Program Files\Java\jdk1.6.0_22\lib\tools.jar;C:\c\server\jbossas-vms\jboss-6.0.0.Final\bin\run.jar
===============================================================================
Notice that JBoss AS echoes my new settings on start up.
Side Note
My PM (@Work) notes and shares that, in Microsoft Windows 32 bit environment, you would not be able to set a value higher than 1024 for your JVM in most cases. Look at this forum thread for some discussion on it http://www.minecraftforum.net/viewtopic.php?f=10&t=167193. Can someone elaborate some on this please? =p
Reference
Managing deployment to JBoss Application Server using Maven through Cargo plugin
Mar 19th
Application Server: JBoss Application Server 6.0.0 Final http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/
Sometime ago, i attempted to deploy a JSF 2.0 web application to the newly released GlassFish Application Server 3.1 through the Maven-Cargo plugin. http://java.sg/managing-deployments-to-application-servers-using-maven-through-cargo-plugin/
Cargo is a truly portable plugin that allows you to deploy to most application server vendors and version.
This code snippet shows the same with JBoss Application Server 6.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Virtualization Management Console</name>
<url>java.sg</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${facelets.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primeFaces.version}</version>
</dependency>
<dependency>
<!-- For primefaces theme http://www.primefaces.org/themes.html -->
<groupId>org.primefaces.themes</groupId>
<artifactId>blitzer</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-core-tools-jboss-deployer-5.1-and-onwards</artifactId>
<version>${cargo.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.GA</version>
</dependency>
</dependencies>
<build>
<finalName>vms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<!-- JBoss 6 AS Community -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo.version}</version>
<configuration>
<container>
<containerId>jboss6x</containerId>
<home>${jbossas.home}</home>
</container>
<configuration>
<type>standalone</type>
<home>${jbossas.server}</home>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<type>war</type>
<properties>
<context>/vms</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
<!-- http://community.jboss.org/wiki/MavenGettingStarted-Developers -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>codehaus-snapshots</id>
<url>http://ci.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<properties>
<junit.version>4.8.2</junit.version>
<primeFaces.version>2.2.1</primeFaces.version>
<faces.version>2.0.3</faces.version>
<javaee.version>1.0.0.Final</javaee.version>
<facelets.version>1.1.15.B1</facelets.version>
<cargo.version>1.0.6</cargo.version>
<jbossas.home>C:\c\server\jbossas-vms\jboss-6.0.0.Final</jbossas.home>
<jbossas.server>${jbossas.home}\server\default</jbossas.server>
</properties>
</project>
To deploy, simply issue the following command in the same directory as where your pom.xml descriptor is sitting.
$ mvn cargo:deploy
You should see output similar to this:
bash-3.2$ mvn cargo:redeploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Virtualization Management Console 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cargo-maven2-plugin:1.0.6:redeploy (default-cli) @ web.vms ---
[INFO] [talledLocalContainer] Parsed JBoss version = [6.0.0]
[INFO] [stalledLocalDeployer] Undeploying [C:\c\server\jbossas-vms\jboss-6.0.0.Final\server\default/deploy/vms.war]...
[INFO] [stalledLocalDeployer] Deploying [C:\c\development projects\project ejb3.1\ide_workspace\ejb3.1_eclipse_workspace\web.vms\target\vms.war] to [C:\c\server\jbossas-vms\jboss-6.0.0.Final\server\default/deploy]...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.929s
[INFO] Finished at: Sat Mar 19 15:29:44 SGT 2011
[INFO] Final Memory: 6M/150M
[INFO] ------------------------------------------------------------------------


