java.lang.OutOfMemoryError

Do you get the following error when building WSO2 products?

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 07:57 min
[INFO] Finished at: 2019-04-12T01:16:28+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] PermGen space -> [Help 1]
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass (URLClassLoader.java:449)
at java.net.URLClassLoader.access$100 (URLClassLoader.java:71)
at java.net.URLClassLoader$1.run (URLClassLoader.java:361)
at java.net.URLClassLoader$1.run (URLClassLoader.java:355)
at java.security.AccessController.doPrivileged (Native Method)
at java.net.URLClassLoader.findClass (URLClassLoader.java:354)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
at org.codehaus.plexus.archiver.AbstractArchiver.addDirectory (AbstractArchiver.java:262)
at org.codehaus.plexus.archiver.AbstractArchiver.addDirectory (AbstractArchiver.java:255)
at org.apache.maven.plugin.war.WarMojo.performPackaging (WarMojo.java:228)
at org.apache.maven.plugin.war.WarMojo.execute (WarMojo.java:177)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
[ERROR]
[ERROR]

Solving: Building WSO2 Carbon needs additional memory allocated to Maven. You can set it as below.

  1. Edit /etc/profile as below.

sudo vi /etc/profile

JAVA_HOME=/usr/java/jdk1.7.0_80export JAVA_HOMEM2_HOME=/home/cloud-user/apache-maven-3.0.5export M2_HOMEexport MAVEN_OPTS="-Xms1024m -Xmx1G -XX:PermSize=1024m -noverify"PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$M2_HOME/binexport PATH

2. source /etc/profile

Rebuild the product.

Senior Software Engineer — QA at WSO2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store