Saturday, October 9, 2010

Building Carbon from the trunk

-->

WSO2 Carbon is the base platform for WSO2’s enterprise-grade middleware stack and as a start up work I spent some time on checking out Carbon from the trunk and building it. This post describes how I managed to accomplish this and some problems I encountered while doing so, and the way I got them solved.

Requirements


Before building carbon I was required to install subversion and maven. This was done using following commands ( in a Linux environment ).

$ sudo apt-get install subversion

$ sudo apt-get install maven2

Then I used the following command to checkout the carbon from trunk.



In the carbon_home directory the POM, "Project Object Model", which is an XML representation of a Maven project held in a file named pom.xml can be found. I could obtain more knowledge about POM from here.


In the pom.xml file, which resides at the root level, the order of modules to be built can be found. For example, as per the below mentioned xml code snippet you have to start from the dependencies module and proceed with orbit, core, components, features and products.

dependencies
orbit
core
components
features
products

Dependencies directory need to be built in the order specified under the pom.xml in the dependencies directory. I used the following order of commands to accomplish this.

$ cd /home/randi/carbon/dependencies/axiom
$ mvn clean install 

-->
Before building ~/dependencies/axis2 I built the following two sub directories first.


$ cd /home/randi/carbon/dependencies/axis2/modules/tool/axis2-mar-maven-plugin
$ mvn clean install

$ cd /home/randi/carbon/dependencies/axis2/modules/tool/axis2-aar-maven-plugin
$ mvn clean install

Then the axis2 module was built.
$ cd /home/randi/carbon/dependencies/axis2
$ mvn clean install


-->
Then the same process was carried out for all the other modules inside the dependencies directory.

-->
In order to skip tests while building I used the following command.

$ mvn clean install -Dmaven.test.skip=true


 

-->
After successfully building ~/carbon/dependencies, I could build other modules as shown below.

-->
$ cd ~/carbon/orbit
$ mvn clean install -Dmaven.test.skip=true

$ cd ~/carbon/core
$ mvn clean install -Dmaven.test.skip=true

$ cd ~/carbon/components
$ mvn clean install -Dmaven.test.skip=true

$ cd ~/carbon/features
$ mvn clean install -Dmaven.test.skip=true

$ cd ~/carbon/products
$ mvn clean install -Dmaven.test.skip=true


$ sudo gedit /usr/bin/mvn
$ sudo gedit /etc/security/limits.conf 

-->
Problems encountered

while trying to accomplish the above task, I ecountered some problems as shown below.

"mvn clean install" crashes with java.lang.OutOfMemoryError: PermGen space after update to java 1.6.0_04


The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.compiler.javac.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:56)
at com.sun.tools.javac.main.JavaCompiler.(JavaCompiler.java:300)
at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:72)
at com.sun.tools.javac.main.Main.compile(Main.java:340)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:549)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:156)
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:605)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)

[INFO] 1error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Failure executing javac, but could not parse the error:


I could overcome this by appending following line to /usr/bin/mvn.

sudo gedit /usr/bin/mvn (to open the file from gedit).

Then I added following line to the file.

export MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=128M"

  -------------------------------------------------------------------------------------------------------------------------------------
-->
When building the dependencies, I got the following build error message.

[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Synapse - Distribution
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [remote-resources:process {execution: default}]
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [assembly:single {execution: distribution-package}]
[INFO] Reading assembly descriptor: src/main/assembly/bin.xml
[INFO] Processing DependencySet (output=synapse-${synapse.version}/lib)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to create assembly: Failed to retrieve OS environment variables. Reason: Cannot run program "env": java.io.IOException: error=24, Too many open files

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 minutes 44 seconds
[INFO] Finished at: Tue Sep 28 10:07:38 IST 2010
[INFO] Final Memory: 377M/665M
[INFO] ------------------------------------------------------------------------



to overcome this I did the following modifications to files.

I added following two lines to /etc/security/limits.conf .
soft nofile 2048
hard nofile 4096



further to set up user limits according to /etc/security/limits.conf, I added following line to /etc/pam.d/login

session required pam_limits.so

Then rebooting and building dependencies again solved my problem.