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

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

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

Hibernate throws Exception “Simultaneously Fetch Multiple Bags”

Problem: Hibernate throws Exception “Simultaneously Fetch Multiple Bags”

I try the 3rd solution introduced in this entry, and it does work!

The third solution is to replace java.util.List and java.util.Collection with java.util.Set. We have to think about it – do we really need a List/Collection (a bag)? In many cases the only reason to use a List is that we are used to.

read more at http://jroller.com

28 December 2009 at 21:25 - Comments

[GAE/J] Path to development console

Remember the followings quoted from Google App Engine intro

The development web server includes a console web application. With the console you can browse the local datastore.

To access the console, visit the URL /_ah/admin on your server: http://localhost:<port>/_ah/admin

gae_admin_console

16 December 2009 at 21:40 - Comments