Changing Liferay Password in database

Note : Use caution while trying this for the production installation. For production, it’s better to use technics like “Forgot Password”

If you forget password for your local admin account in Liferay, then stop the server and run the following command

Where mynewpassword is your new password. Now restart the server. This time you should be able to login with your new password. As soon as you login, Liferay should prompt you for password change. Change your password and try to remember it this time ūüėČ

How to set lower_case_table_names in MAMP

Environment – Mac OS X
I have struggled a little to set lower_case_table_names =2 for mysql using MAMP. I have unsuccessfully tried configuring /etc/my.cnf and ~/.my.cnf. Finally (with a little help) I found that they are setting this value in MAMP/bin/ . Location of this file might differ because in your version of MAMP.
My config file looks like this

Change this file to set it to required value. As you might have guessed, you can use the same approach to update other params like log-error location, or port number (port number can be changed from MAMP preferences too)

Luke – Incompatible format version: 2 expected 1 or lower

I was trying to analyze my Lucene index generated by Nutch and I was getting this error when I selected Lucene index directory

Incompatible format version: 2 expected 1 or lower
And on the console it had


I got away with this using latest Luke Jar (luke-all-1.0.1). You can download it from

generate-all No domain class found for.. error in grails

Short Story: Provide fully qualified domain class name(class name with the package) to the generate-all command

Long Story:

If you have recently moved from pre-1.3 to latest grails version(1.3.2 as of today) and suddenly you have started getting this error

No domain class found for name Book. Please try again and enter a valid domain class name

on generate-all command

grails generate-all Book

then don’t panic. As of grails-1.3.2, when you create a new domain class, it is generated in a package. For example, in my case my Book.groovy is generated under mylib package(mylib is the name of my application)

generate-all command requires you provide fully qualified class names. This is true for even older versions like 1.1.1.

Issue this command instead

grails generate-all mylib.Book

I wish they made this point clear in their documentation at

Exact Target Client in Java

      5 Comments on Exact Target Client in Java

Disclaimer – Most of the code in this post are from the code samples provided by Exact Target. I have encountered little difficulties in using the code samples. Therefore I am writing this post to document how I made it work finally. Hope it helps.

Recently, We have implemented Grails/Java client for Exact Target .net webservices. We have use Axis 1.4 to generate the exact target client. ET provides very good samples and examples. Our implementation was derived from one of the sample project they have provided.

Important Note: Exact Target has released new version of webservices recently. If that is the case then this post may not be of much help. This post is based on the following environment. If your environment is different then YMMV.

Java 5+, Axis 1.4, Exact Target Partner API 1.0, Apache Ant

These are the steps we have followed

i) Create a new java project and have the structure similar to this

Few files to take note of.

  • build.xml
  • etframework.wsdl
  • Code generated by wsdl2java will be in src/com.exacttarget.wsdl.partnerapi package
  • com.exacttarget.samples.Axisv14.client.ClientTest is used to test the client and com.exacttarget.samples.Axisv14.client.PWCBHandler is the implementation of Password Callback Handler
  • jars in the lib folder . These jars may be required to make things work.
  • client_deploy.wsdd is used by the framework
  • Generated client jar will be put in dist/lib/ folder
  • Folder build/com will have the compiled classes.

Normal java project stuff. Shouldn’t be new to you!

Now let’s get our hands dirty

ii) Open the and update your api username and password

 * Copyright 2004,2005 The Apache Software Foundation.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package com.exacttarget.samples.Axisv14.client;




 * Modified WSS4J callback handler to accept user and password information from properties file via ClientTest.
 * The original class from Apache required hard-coded values for this information. This class may be further
 * modified for production usage so that this information is fetched from any external store, such as a database.
 * @author Erik Gfesser
public class PWCBHandler implements CallbackHandler {
 public static String user = "myusername";
 public static String password = "mypassword";

 public void handle(Callback[] callbacks) throws IOException,
 UnsupportedCallbackException {

 for (int i = 0; i < callbacks.length; i++) {
 if (callbacks[i] instanceof WSPasswordCallback) {
 WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
 String id = pwcb.getIdentifer();
 if(user.equals(id)) {
 } else {
 throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
 } //end method handle
} //end class PWCBHandler

For your reference here is how client_deploy.wsdd looks like

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="" xmlns:java="">
<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
 <handler type="">
 <parameter name="action" value="UsernameToken"/>
 <parameter name="user" value="myuserid"/>
 <parameter name="passwordCallbackClass" value="com.exacttarget.samples.Axisv14.client.PWCBHandler"/>
 <parameter name="passwordType" value="PasswordText"/>

And last but not the least, here is the build.xml

<project basedir=".">
 <property name="build.dir" value="build"/>
 <property name="lib.dir" value="lib"/>
 <property name="resources.dir" value="resources"/>
 <property name="src.dir" value="src"/>
 <property name="dist.dir" value="dist"/>

 <path id="axis.jaf.javamail.wss4j.xmlsec.xerces.lib.classpath">
 <fileset dir="${lib.dir}">
 <include name="*.jar"/>

 <path id="client.lib.classpath">
 <fileset dir="${dist.dir}/lib" >
 <include name="*.jar" />

 <target name="init">
 <mkdir dir="${build.dir}"/>
 <mkdir dir="${dist.dir}/lib"/>

 <target name="generate.client" depends="init">
 <taskdef resource=""
 <axis-wsdl2java url="${resources.dir}/META-INF/etframework.wsdl"
 <mapping namespace=""
 package="com.exacttarget.wsdl.partnerapi" />

 <target name="compile.client">
 <javac destdir="${build.dir}"
 <src path="${src.dir}"/>
 <classpath refid="axis.jaf.javamail.wss4j.xmlsec.xerces.lib.classpath"/>
 <jar destfile="${dist.dir}/lib/mysample-exacttarget-client-1.0.jar"

 <target name="generate.compile.client" depends="generate.client,compile.client"/>

 <target name="clean">
 <delete dir="${build.dir}"/>

iii) Run ant generate.client to generate the client classes. This target uses wsdl2java to generate java code from wsdl. After
this target is successfully run you should see java classes under com.exacttarget.wsdl.partnerapi package

iii) Now you should try to test the generated client. We will make use of for the same. Here is a part of
I have. Again the basic templated was given by ET itself

package com.exacttarget.samples.Axisv14.client;

import java.rmi.RemoteException;
import java.util.Properties;

import javax.xml.rpc.ServiceException;

import org.apache.axis.EngineConfiguration;
import org.apache.axis.configuration.FileProvider;

import com.exacttarget.wsdl.partnerapi.APIObject;
import com.exacttarget.wsdl.partnerapi.Attribute;
import com.exacttarget.wsdl.partnerapi.CreateOptions;
import com.exacttarget.wsdl.partnerapi.CreateRequest;
import com.exacttarget.wsdl.partnerapi.CreateResponse;
import com.exacttarget.wsdl.partnerapi.CreateResult;
import com.exacttarget.wsdl.partnerapi.DefinitionRequestMsg;
import com.exacttarget.wsdl.partnerapi.DefinitionResponseMsg;
import com.exacttarget.wsdl.partnerapi.Email;
import com.exacttarget.wsdl.partnerapi.List;
import com.exacttarget.wsdl.partnerapi.ListSubscriber;
import com.exacttarget.wsdl.partnerapi.ObjectDefinition;
import com.exacttarget.wsdl.partnerapi.ObjectDefinitionRequest;
import com.exacttarget.wsdl.partnerapi.Owner;
import com.exacttarget.wsdl.partnerapi.PartnerAPI;
import com.exacttarget.wsdl.partnerapi.PartnerAPILocator;
import com.exacttarget.wsdl.partnerapi.RetrieveRequest;
import com.exacttarget.wsdl.partnerapi.RetrieveRequestMsg;
import com.exacttarget.wsdl.partnerapi.RetrieveResponseMsg;
import com.exacttarget.wsdl.partnerapi.Send;
import com.exacttarget.wsdl.partnerapi.SimpleFilterPart;
import com.exacttarget.wsdl.partnerapi.SimpleOperators;
import com.exacttarget.wsdl.partnerapi.Soap;
import com.exacttarget.wsdl.partnerapi.Subscriber;
import com.exacttarget.wsdl.partnerapi.TriggeredSend;
import com.exacttarget.wsdl.partnerapi.TriggeredSendCreateResult;
import com.exacttarget.wsdl.partnerapi.TriggeredSendDefinition;

 * Example to show Axis 1.4 usage pattern as a client to invoke services from
 * ExactTarget Integration Framework Web Service API endpoint.
 * @author Erik Gfesser
public class ClientTest {
 static String user = null;
 static String password = null;
 static String clientWSDD = null;
 static String customerKey = null;
 static String validEmailAddress = null;
 static String validSubscriberKey = null;
 static String validFromAddress = null;
 static String validFromName = null;
 static String invalidEmailAddress = null;
 static String invalidSubscriberKey = null;
 static String invalidFromAddress = null;
 static String invalidFromName = null;

 public static void main(String[] args) throws ServiceException,
 RemoteException {
 EngineConfiguration config = new FileProvider(clientWSDD);

 // Create PartnerAPI stub with ExactTarget Web Service API endpoint and
 // Axis configuration
 PartnerAPI service = new PartnerAPILocator(config);
 Soap stub = service.getSoap();

 testET( stub );

 } // end method main

In the testET method you can use any one of the ET API method to test the connectivity to the ET is working or not.

iv) If it works then you can generate the ET jar using compile.client ant target and you may use this jar as ET client in your target projects.

Grails EHCache Settings

      No Comments on Grails EHCache Settings

We have configured Ehcache as second level hibernate cache for our project. This post is for Grails 1.1.1 projects. In the later version of grails, the configuration can be little different. Here are the steps. (It is quite some time when I did the actual configuration. Let me know if I missed something)


First of all we have put ehcache.xml in grails-app/conf directory. Our config file looks like this.  You may modify the config based on your preferences. To learn more about this settings go to

<ehcache xmlns:xsi=""

 <cache name="org.hibernate.cache.UpdateTimestampsCache"

 <cache name="org.hibernate.cache.StandardQueryCache"


ii) Modify the cache provider class in your DataSource.groovy to org.hibernate.cache.EhCacheProvider like this

hibernate {

iii) Now to fine-tune your cache setting, go to individual domain classes for which you want to enable ehcache and add the following mapping closure with cache true

class Employee {
    String name
    static constraints = {

    static mapping = {
        cache true

iv) If you want your query to be cached, you can configure it similarly with cache true clause

		def employeeList = Employee.createCriteria().list() {
			or {
			order(".....", "...")
			cache true

For further reading to to

How to switch to INNODB database in mysql

MySQL support many storage engines. If you run the following command you can see all the storage engines supported by your mysql version.

show engines;

For the performance reasons MyISAM is the default storage engine.  In some cases, you might want to change this to different engine, like  InnoDB for transaction support etc.

There are couple of ways of doing it. I know three of them

1. Change my.cnf file.

MySQL reads from my.cnf to read the default configuration settings. This file is generally found in /etc/my.cnf or $USERHOME/.my.cnf in *nix/mac  or c: or installdirectory or windows directory in window. In my.cnf file have this configuration


default-storage-engine = InnoDB

Also, have the following  lines or uncomment them if already present. Make sure the innodb_data_home_dir etc points to a valid location

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

2. SET storage_engine=INNODB

If you want your storage engine changed to something else for just the current session you can run the following command

SET storage_engine=InnoDB

3. Use engine=INNODB per table

You can change the engine per table like this

CREATE TABLE employee (id INT) ENGINE = InnoDB;

or if you have existing table and you want to change the engine


Error while configuring mysql for Alfresco

Today while configuring mysql database for my Alfresco, I started getting these type of errors

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate key name ......

This error was coming when it was running this script


Then I realized that mysql on my macine was not using INNODB engine by default. I dropped the database and created again using innodb engine and it worked

Restoring Drupal from a backup using CPanel

Recently I had to move one of our Drupal site from one server to another. I was given the tar file containing the backup including the mysql script files. I strongly recommend you to go through expert blogs and sites for the complete information about this topic. I am writing my own experience

  1. The core Drupal installation is within the public_html folder. You can see this file folder within your backup files  directories.  In my case my public_html file was within a tar file named homedir.tar within my main backup file. public_html folder should contain folders like modules, profiles, INSTALL.txt etc. This is the base folder for your drupal installation. You have to copy this folder within public_html folder of your server. If your domain is the contents of public_html(modules, profiles etc) will be right within public_html/www folder. If you have a sub-blog then you have to copy the contents withing the subfolder. Following steps will assume that you are copying directly under public_html
  2. Using Cpanels, MySql Databases application, create a new database, create a new user and add this user with all the privileges to that database.
  3. Open public_html/sites/default/settings.php and set db_url value as per the database and user you have created in previous step
  4. Core data of your drupal website resides in mysql. Now you will have to import mysql database from the backup file to the newly created database. There are several ways of doing it. If you have ssh access you can go to the database and simply import the .sql file. I found phpadmin easy. For that, first you have to open your backup mysql script file(in my case it was a file under mysql folder in the backup. If there are more than one files then size of the files should give you fair idea which is the right file. Normally, file name should begin with the database name in your previous server) As a first statement in that sql file write this
    use mydb

    Where mydb is the name of the data. Usually when you select database in phpmyadmin before import then this step is not required. But it never hurts(less surprises this way)

  5. Open phpmyadmin, select your database from left lift, go to import tab and import this sql file
  6. Upto this step your website should be restored. If not, then probably you missed something. If you have not implemented clean url in your blog, then you don’t have to do anything else. Clean url converts the url in this format to
  7. If you have implemented clean url, on clicking any link you might be getting 404 error. To correct this you have to have .htaccess file properly configured. This is just an example

# Apache/PHP/Drupal settings:

# Protect files and directories from prying eyes.
<Files ~ "(.(inc|module|pl|sh|sql|theme|engine|xtmpl)|Entries|Repositories|Root|scripts|updates)$">
 Order deny,allow
 Deny from all

# Set some options.
Options -Indexes
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More exist in sites/default/settings.php, but
# the following cannot be changed at runtime. The first IfModule is
# for Apache 1.3, the second for Apache 2.
<IfModule mod_php4.c>
 php_value magic_quotes_gpc                0
 php_value register_globals                0
 php_value session.auto_start              0

<IfModule sapi_apache2.c>
 php_value magic_quotes_gpc                0
 php_value register_globals                0
 php_value session.auto_start              0

# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
 ExpiresByType text/html A1

# Various rewrite rules.
<IfModule mod_rewrite.c>
 RewriteEngine on

 # Modify the RewriteBase if you are using Drupal in a subdirectory and
 # the rewrite rules are not working properly.
 #RewriteBase /drupal

 # Rewrite old-style URLs of the form 'node.php?id=x'.
 #RewriteCond %{REQUEST_FILENAME} !-f
 #RewriteCond %{REQUEST_FILENAME} !-d
 #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
 #RewriteRule node.php index.php?q=node/view/%1 [L]

 # Rewrite old-style URLs of the form 'module.php?mod=x'.
 #RewriteCond %{REQUEST_FILENAME} !-f
 #RewriteCond %{REQUEST_FILENAME} !-d
 #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
 #RewriteRule module.php index.php?q=%1 [L]

 # Rewrite current-style URLs of the form 'index.php?q=x'.
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.66 2005/03/20 19:15:00 dries Exp $

This should complete your backup restoration. If you have any issues you can post comments here.