Thursday, March 08, 2007

Load a resource file in ear environment

Three issues
1. the properties files must be in the class path of the application module trying to read it
2. you have to use the correct class loader (Thread.currentThread().getContextClassLoader()).
3. call classloader's getResource(String propResource) method.

It will not work by simply using ClassLoader.getSystemResource() method.

Thursday, March 01, 2007

two tips

Regular Expressions:
using $1, $2.. to match find result. use () to group characters. * + are applied after the searching characters. using \w for all alphanumeric char.

How to throw business exception in web service calls.
The best way is to define some serializable fields when creating the exception class which will be returned by a web service method call. Otherwise when calling wsdl2java, it will automatically create a message field and getMessage() for you, which will cause problem in RAD tool. The reason for all this I guess is because the Exception class itself is not Serializable, and its fields can not be transfered. So it requires developer to create a subclass of Exception with its own fields to hold the exception code and message. Which can be shown within the fault segment.