Tuesday, September 28, 2010

Installing SUN JDK6 on Ubuntu 9.10 Karmic of EC2

It does not come easy/handy to install sun jdk6 on Ubuntu Karmic.


  1. Open deb repositories
     sudo emacs /etc/apt/sources.list 

  2. Append your ubuntu's mirror site to it

    deb http://us-west-1.ec2.archive.ubuntu.com/ubuntu/ karmic main universe
    deb-src http://us-west-1.ec2.archive.ubuntu.com/ubuntu/ karmic main universe
    deb http://us-west-1.ec2.archive.ubuntu.com/ubuntu/ karmic-updates main universe
    deb-src http://us-west-1.ec2.archive.ubuntu.com/ubuntu/ karmic-updates main universe
    deb http://security.ubuntu.com/ubuntu karmic-security main universe
    deb-src http://security.ubuntu.com/ubuntu karmic-security main universe
    deb http://us.archive.ubuntu.com/ubuntu karmic main multiverse

  3. Update packages
    sudo aptitide update

  4. Install SUN JDK6
    sudo apt-get install sun-java6-jdk

  5. Verify the installation

    tiger:/etc/apt$ java -version
    java version "1.6.0_15"
    Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
    Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)

Friday, September 24, 2010

Don't forget to append file:// properties you specified at runtime

I am using spring and supply properties at runtime to make my application flexible that can be deployed with different settings. The typical usage is to combine property placeholder and context place holder:


classpath:myappAnalyticsWS.properties
${runtime.config}


You can supply properties in runtime.properties and the resource can be a local file such as c:/runtime/customization-runtime.properties. The gotcha is that you could be careful to specify the schema. For instance:


export CATALINA_OPTS = "CATALINA_OPTS -D -Druntime.config=$CATALINA_HOME/cutomization-runtime.properties"


would not work. You would get error such as:

010-09-24 20:38:38,197 ERROR [main] context.ContextLoader (ContextLoader.java:215) - Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [$CATALINA_HOME/cutomization-runtime.properties]
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostP



Fortunately it is very easy to fix it by simply specifying the schema:

export CATALINA_OPTS = "CATALINA_OPTS -D -Druntime.config=file://$CATALINA_HOME/cutomization-runtime.properties"