Wednesday, April 07, 2010

Patching Liferay

If you even find a bug with Liferay as I recently did you might want to go ahead and patch yourself Liferay before actually the team comes with a new release.

1. Run the below from the root liferay source folder directory
ant clean start build-ext

2. After you do that you can build individual jars. In my case portal-impl.jar contains a buggy class in version 5.2.3. After I fixed the problem I just run the below from the portal-impl folder:
ant deploy

3. Stop the application server.

4. Copy the jar to liferay application WEB-INF/lib replacing that way the original file in there, for example:
cp portal-impl.jar ~/glassfishv3/glassfish/domains/liferay-domain/applications/liferay-portal-5.2.3/WEB-INF/lib/

5. Start the application Server.

Monday, April 05, 2010

Maven java.lang.OutOfMemoryError: Java heap space

Days ago our deployment scripts started to fail for some packages with error:
java.lang.OutOfMemoryError: Java heap space

It was solved adding the below to pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.2</version>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>

However tonight it happened again. The build was taking too long and when inspecting the java process it was not launched with -Xmx1024m option so the below did the trick:
export MAVEN_OPTS=-Xmx1024m

Deserializing JSON with gson

I have done lot of JSON serialization/deserialization using the gson library. I wanted just to share one very handy class that I have recommended twice this week with great results I heard from a couple of friend developers.

As its name indicates (GeneralObjectDeserializer) using it you will be able to Deserialize a JSON Object into a General Object. The resulting object is based on Map and Array, fair enough. No need to say the approach is simple and just works.

The plugin 'org.codehaus.mojo:buildnumber-maven-plugin' does not exist or no valid version could be found

I work with people that use different IDEs. I use Maven and I find myself quite frequently issuing the below commands:

mvn eclipse:clean
mvn eclipse:eclipse

It has been working for ages and yesterday it started failing for me:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.codehaus.mojo:buildnumber-maven-plugin' does not exist or no valid version could be found
This used to work:

My plugin configuration was not using version but again it was working before:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>

Here is how I solved this:
1. Add the version number to the pom.xml declaration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-4</version>

2. Download the dependency:
wget http://mirrors.ibiblio.org/pub/mirrors/maven2/org/codehaus/mojo/buildnumber-maven-plugin/1.0-beta-4/buildnumber-maven-plugin-1.0-beta-4.jar

3. Install it locally or in your Maven repo. Showing locally installation here:
mvn install:install-file -Dfile=buildnumber-maven-plugin-1.0-beta-4.jar \
-DgroupId=org.codehaus.mojo \
-DartifactId=buildnumber-maven-plugin \
-Dversion=1.0-beta-4 \
-Dpackaging=jar

Sunday, April 04, 2010

Liferay Tips And Tricks

I have decided to open a WIKI page for Liferay Tips and Tricks. Hopefully that will help me on the eternal task of providing as fast as possible solutions.

Followers