Author Archive

MVN Tips: building a part of a multi-module project

Build specific modules instead of building all modules in a multi-module projects

Use the Maven advanced reactor options:

-pl, –projects Build specified reactor projects instead of all projects -am, –also-make If project list is specified, also build projects required by the list

In the parent project’s directory, run

mvn install –projects projB

This will build projB and the modules required by projB.

More info: http://www.sonatype.com/people/2009/10/maven-tips-and-tricks-advanced-reactor-options/

17 April 2011 at 07:28 - Comments

Google GIN – A basic tutorial

17 July 2010 at 17:45 - Comments

How to work around when java.lang.Boolean is in the black list of LegacySerialiaytionPolicy

It took me a while to figure out that java.lang.Boolean is in the blacklist of the LegacySerializationPolicy class. Therefore when my RPC service tries to transfer java.lang.Boolean object, it throws Exception

"Type '*java.lang.Boolean*' was not included in the set of types which can be serialized 
by this SerializationPolicy or its Class object could not be loaded.
For security purposes, this type will not be serialized."

 

Look at the class com.google.gwt.user.server.rpc.impl.LegacySerialiaytionPolicy

  /**
   * Many JRE types would appear to be {@link Serializable} on the server.
   * However, clients would not see these types as being {@link Serializable}
   * due to mismatches between the GWT JRE emulation and the real JRE. As a
   * workaround, this blacklist specifies a list of problematic types which
   * should be seen as not implementing {@link Serializable} for the purpose
   * matching the client's expectations. Note that a type on this list may still
   * be serializable via a custom serializer.
   */
  private static final Class<?>[] JRE_BLACKLIST = {
      java.lang.ArrayStoreException.class, java.lang.AssertionError.class,
      java.lang.Boolean.class, java.lang.Byte.class, java.lang.Character.class,
      java.lang.Class.class, java.lang.ClassCastException.class,
      java.lang.Double.class, java.lang.Error.class, java.lang.Float.class,
      java.lang.IllegalArgumentException.class,
      java.lang.IllegalStateException.class,
      java.lang.IndexOutOfBoundsException.class, java.lang.Integer.class,
      java.lang.Long.class, java.lang.NegativeArraySizeException.class,
      java.lang.NullPointerException.class, java.lang.Number.class,
      java.lang.NumberFormatException.class, java.lang.Short.class,
      java.lang.StackTraceElement.class, java.lang.String.class,
      java.lang.StringBuffer.class,
      java.lang.StringIndexOutOfBoundsException.class,
      java.lang.UnsupportedOperationException.class, java.util.ArrayList.class,
      java.util.ConcurrentModificationException.class, java.util.Date.class,
      java.util.EmptyStackException.class, java.util.EventObject.class,
      java.util.HashMap.class, java.util.HashSet.class,
      java.util.MissingResourceException.class,
      java.util.NoSuchElementException.class, java.util.Stack.class,
      java.util.TooManyListenersException.class, java.util.Vector.class};

 

How to work around ?

Use a custom serializable class instead of java.lang.Boolean

import com.google.gwt.user.client.rpc.IsSerializable;

public class SerializedBoolean implements IsSerializable {

    private boolean value;

    public static final SerializedBoolean TRUE = new SerializedBoolean(true);
    public static final SerializedBoolean FALSE = new SerializedBoolean(false);

    public SerializedBoolean(){
        value = false;
    }

    public SerializedBoolean(boolean value){
        this.value = value;
    }

    public boolean isValue() {
        return value;
    }

    public void setValue(boolean value) {
        this.value = value;
    }

}
7 July 2010 at 05:55 - Comments

Eclipse ${user} variable

To change the ${user} variable, add the following line into the file eclipse.ini

-Duser.name=Your Name

29 April 2010 at 09:51 - Comments

Fix: Cannot perform SVN CHECKOUT from code.google.com

code.google.com is down ? I don’t really know what happened. For a few hours i could not perform SVN checkout from code.google.com. It worked fine in some projects, while the others did not. When i used web browser to open the source tab of the broken project, it redirected to “Google Server Error” page.

I found out that  SVN COMMIT still worked. I tried to commit a dummy change, and later on, SVN CHECKOUT worked again.Why is that ?

28 April 2010 at 18:02 - Comments

Gia Tài Của Vợ

I just found this funny song on YouTube. This is a joke song based on “Gia Tài Của Mẹ” (by Trịnh Công Sơn).

Gia Tài Của Vợ

(Theo nhạc bài “Gia tài của mẹ” của Trịnh Công Sơn)

Một nghìn năm nô lệ vợ nhà Một nghìn năm nô lệ vợ ta Hai mươi năm rửa chén chùi nhà Gia tài của vợ, để lại cho ta Gia tài của vợ, là một khối việc nhà

Một nghìn năm ta sợ đàn bà Một trăm năm ta sợ vợ ta Hai mươi năm làm hết việc nhà Ôi còn gì là, một đời trai tơ Chỉ còn lại là, một kiếp chồng khờ

Nàng dạy ta biết nấu thịt bò Nàng dạy ta biết kho thịt kho Ta biết kho thịt kho, cho thật ngon Nàng dạy ta rửa chén, chùi nhà Nàng dạy ta biết mua đồ sale, Ôi biết bao là ơn, ơn vợ nhà

Một nghìn năm đi làm người chồng Một nghìn năm trong đời xiềng gông Hai mươi năm làm kiếp lòng thòng Ôi còn gì là, ngoài bộ xương teo Chỉ còn lại là, một kiếp bọt bèo

Đời đàn ông như vậy là thường, Đời đàn ông nghĩ lại mà thương Con con ơi hãy cố noi gương Hãy làm việc gì thì đừng bê tha Cho dù sợ bà thì (là) cũng bà nhà Dạy cho con khí phái chùi nhà Dạy cho con biết ơn người ta, con biết ơn người ta, không rên la. Dạy cho con biết quí đàn bà Dạy cho con biết như người cha, con biết như việc cha, vui việc nhà

1 April 2010 at 19:05 - Comments

Some common errors when developing GWT apps

1. Use GWT.create(MyServiceAsync.class) instead of GWT.create(MyService.class)

For example:

import com.google.gwt.core.client.GWT;

public class ServiceFactory {

	private static MyServiceAsync myService = null;

	public static SecurityServiceAsync getMyService() {
		if (myService == null)
			myService = GWT.create(MyServiceAsync.class);

		return myService;
	}

}

You will get the following exception when invoking the MyService

 

Deferred binding result type ‘com.mycompany.myapp.client.MyService’ should not be abstract

Uncaught exception escaped

java.lang.RuntimeException: Deferred binding failed for 'com.mycompany.myapp.client.MyServiceAsync' (did you forget to inherit a required module?)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:43)
    at com.google.gwt.core.client.GWT.create(GWT.java:98)
    at com.mycompany.myapp.client.ServiceFactory.getMyService

 

2. CSS files are not found after deploying on appspot.com

On appspot.com, filename is case-sensitive. But in Windows, filename is case-insensitive.

21 February 2010 at 19:41 - Comments

Kristine Sa Show: Interview with Leyna Nguyen

Today i introduce another show from Kristine Sa. This is an interview with Leyna Nguyen.

For short, Leyna is a TV anchor at KCAL-TV in Los Angeles (in Vietnamese “người dẫn chương trình truyền hình”)

She gains success in her career. But i dont want to talk about her success.

I like this lady for the her truly Vietnamese soul. She does not forget her root, and she knows how to teach her children about the ‘nguồn gốc Việt Nam”. I admire her for it.

And i really feel sorry for so many Vietnamese children that i met in Germany. They grew up abroad, and … cannot speak Vietnamese. Day after day they are losing contact with their parents and the community just because they cannot understand Vietnamese.

This show is 90% in English. I am pretty sure that you can understand it if you dont speak Vietnamese.

Please watch the show and share your thoughts.

Đây là chương trình truyền hình Kristine Sa của đài truyền hình Việt Hải Ngoại. Trong chương trình này, Kristine sẽ phỏng vấn cô Leyna Nguyễn, một người Mỹ gốc Việt rất thành công trong lĩnh vực truyền hình tại Mỹ.

Tôi rất ngưỡng mộ Leyna không phải vì thành công của cô trong sự nghiệp mà vì chất Việt đậm đà trong người phụ nữ đa tài này.

 

 

 

 

4 February 2010 at 22:31 - Comments

Install Artifactory in Windows

 

1. Download Artifactory Standalone Zip from jfrog.org

2. Extract the zip file somewhere, let call it $ARTIFACTORY_HOME

3. Run $ARTIFACTORY_HOME\bin\artifactory.bat

Note: You may allow Windows Firewall not to block this application.

 artifactory_start

4. Open the browser, go to http://localhost:8081/artifactory

5. Now you can manage your maven repository.

2 February 2010 at 23:11 - Comments

Hibernate Annotation: length-limited field is not auto truncated

Problem:

Let’s consider a table containing a length-limited field (e.g. COUNTRY_CODE is 2-char length).

CREATE TABLE  `country` (

	`COUNTRY_CODE` varchar(2),
	`COUNTRY_NAME` varchar(255),

) 

- The length value is already specified in Hibernate annotation.

@Column(name="COUNTRY_CODE", length=2)
private String countryCode;

- However when inserting a value length beyond the limit, this value is not automatically truncated, and Hibernate throws the following exception:

Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'COUNTRY_CODE' at row 1

Solution: Use custom SQL :

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.SQLInsert;

/**
* The persistent class for the country database table.
*
*/
@Entity
@Table(name="country")
@SQLInsert(sql="INSERT IGNORE INTO country (country_name, country_code) VALUES(?,upper(?))")
public class Country {

	@Id
	@Column(name="COUNTRY_CODE", length=2)
	private String countryCode;

	@Column(name="COUNTRY_NAME")
	private String countryName;

	//bi-directional many-to-one association to State
	@OneToMany(mappedBy="country")
	private List<State> states;

	//... standard getters and setters

}
25 January 2010 at 21:04 - Comments