Friday, November 20, 2009

My Pirate Name a.k.a Something less serious

My pirate name is:
Dirty Jack Kidd

You're the pirate everyone else wants to throw in the ocean -- not to get rid of you, you understand; just to get rid of the smell. Even though you're not always the traditional swaggering gallant, your steadiness and planning make you a fine, reliable pirate. Arr!
Get your own pirate name from
part of the network

Thursday, November 5, 2009

Preventing ConcurrentModificationExceptions!

I have encountered several times now, and its very annoying since the error happens randomly. After a bit of googling, I found out that using unsynchronized JAVA collections yields unpredictable results. I am hoping that synchronizing my JAVA collections manually could solve this problem. To do this, I will have to use the ready made JAVA Collections synchronize wrapper:

For example if I use the List interface like this before:

List list = new ArrayList();

I will have to wrap the ArrayList implementation using the Collections synchronize method:

List list = Collections.sychronizedList(new ArrayList);


List list = new ArrayList();
list = Collections.sychronizedList(list);

I hope this works. I will refactor my code now and will update this post once I find out what happens.

EDIT: It works! You just have to synchronize the list before iterating through them :)

Wednesday, October 21, 2009

Set Character Encoding to log4j's File Log

Working with east asian characters? Do you want log4j to print out utf-8 characters on your log file? Here is how:

When you're using a file:


When youre using a log4j.xml file:

<appender name="R"
        <param name="File" value="info-log.log"/>
        <param name="Encoding" value="UTF-8"/>

Wednesday, October 7, 2009

Loading a file from classpath

There are instances that you want to load a certain file from your classpath, the following code does that:

private InputStream getFileFromClassPath(String fileName) throws IOException {

        ClassLoader cl = ClassLoader.getSystemClassLoader();
        URL url = cl.getResource(fileName);
        if (url == null) {
            throw new NullPointerException("File with filename " + fileName + " not found on classpath");
        } else {
            return url.openStream();

Tuesday, October 6, 2009

How to define multiple PropertyPlaceholderConfigurer beans

I came across a problem today regarding the app that I am working on wherein I have to define a different PropertyPlaceholderConfigurer bean for each of my context xml files. (Each context xml file is imported in another xml file so it became a little bit tricky).

What I did was, I defined a PropertyPlaceholderConfigurer bean on the first context xml file and I defined another one on the second, so that each context xml can have it's own distinct PropertyPlaceholderConfigurer bean. But upon doing so, I got the following error

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'myClass' defined in class path resource [spring-config.xml]: Could not resolve placeholder 'props.value.2'

After google-ing a bit I found the answer to my problem on an entry on Parth Barot's blog. Please take a look!

Monday, September 28, 2009

Loading a properties file using spring

Example properties file with filename:


On your spring config file, you can load the properties file using the following code

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">

after that, you can now use the values on your properties file by using their key enclosed by a dollar sign and two curly braces. Example code:

<bean id="myUrl" class="">
        <constructor-arg value="${env.protocol}://${}"/>
Spring will now interpret the constructor arg value to be:

Wednesday, April 22, 2009

Spring and Hibernate

Personally, I don't like Spring (maybe because I didnt understand anything when the instructor taught it), but I LIKE hibernate (maybe because I got it on the first try because I just copy / pasted code) xD. SO ANYWAY I have to post code snippets here when I learn enough.

NOTE TO SELF: You have a blog.

(I hope I remember that note after a day or so haha ha.)

UPDATE [September 29, 2009]: Okay now I like Spring, I actually LOVE it. I don't like Hibernate anymore because after 5 months of not using it, I totally forgot how to use the thing. But hey! maybe I'll like it again after a while you never know! :D

Tuesday, February 24, 2009

Gundam 00 S2 - Episode 20

Gundam 00 S2 Ep20 is out! Just woke up this morning, and it's there in it's shining brilliance and beauty! Download the episode via torrent on Get it while it's hot guys!

"Stick 'em up!"

"Don't shoot the pretty girl!"


They didnt show this scene before. O_O

Louise! Dont fall for Ribbons' geass! err.. wrong anime.

Curving beams eh? Reminds me of Hisoka's gummy power something.

Lyle is a really aggressive guy.

Yeah right.

Sunday, February 22, 2009

Line of The Day

"Hi, I seem to have lost my number, can I borrow yours?"

Friday, February 20, 2009

Hello World

Hello This is my first post, I have a lot of plans for this blog, but for the meantime Ill just place a single post here and Ill just edit it afterwards. Okay? Alright...