Category Archives: Uncategorized

Setting up the DB2 database on Ubuntu and testing JDBC connectivity

I got my DB2 database installation running on a Ubuntu 11.10 machine recently, and have documented the steps I carried out below.

Downloading DB2

The express edition is free, and can be downloaded from Download DB2 Express-C. You’ll need to register for an IBM id if you don’t already have one.

Download DB2 Express C Using HTTP

Extracting and installing

Use the command tar -zvxf db2exc_975_LNX_x86.tar.gz to extract the gzipped file. Run the installer using sudo ./db2setup, and choose “Install a Product” on the left menu. The installation process is quite straightforward after this point.

DB2 Setup Launchpad - Install a Product as root

Troubleshooting ‘not found’ when running db2setup

I faced the following problem when I ran the setup script:

$ sudo ./db2setup
   The required library file is not found on the system. 
   Check the following web site for the up-to-date system requirements
   of IBM DB2 9.7  
  Aborting the current installation ...
  Run installation with the option "-f sysreq" parameter to force the installation.

To fix it, I had to run sudo apt-get install libaio-dev to install the missing package.

Verifying the Installation

The following command verifies the db installation and configured instances:

sudo /opt/ibm/db2/V9.7/bin/db2val -a

Creating a database

Switch to the user account that is the owner of the instance (db2inst1 is the default).

$ su db2inst1

Switch to the bash shell if necessary:

$ bash

Under this user account, you can run DB2 commands as illustrated below. Note that the create database command takes time – it took several minutes on my machine.

$ db2 create database test
DB20000I  The CREATE DATABASE command completed successfully.
$ db2 connect to test

   Database Connection Information

 Database server        = DB2/LINUX 9.7.5
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

$ db2 "create table test.technonstop(id int, username varchar(200))"
DB20000I  The SQL command completed successfully.
$ db2 "INSERT INTO test.technonstop VALUES(1, 'abdullah')"
DB20000I  The SQL command completed successfully.


If you’re unable to run any db2 command, the db2 environment variables may not have been sourced. To do it, run the following command at the terminal, replacing db2inst1 with the instance owner.

. /home/db2inst1/sqllib/db2profile

Java Program to Test JDBC Connectivity

I use the following Java program to test to see if JDBC connectivity works from a Java program, after assigning appropriate values to the constants at the beginning:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

public class PrintSQLTable {

	final static String dbdriver = "";
	final static String dburl = "jdbc:db2://localhost:50000/test";
	final static String dbuser = "db2inst1";
	final static String dbpassword = "myPassword";
	final static String dbtable = "test.technonstop";
	public static void main(String[] args) throws ClassNotFoundException,
			SQLException {
		Connection connection = DriverManager.getConnection(dburl, dbuser,
		Statement statement = connection.createStatement();
		ResultSet resultSet = statement
				.executeQuery("SELECT * FROM " + dbtable);

		StringBuilder tableContents = new StringBuilder("");
		ResultSetMetaData metaData = resultSet.getMetaData();
		int noOfColumns = metaData.getColumnCount();

		for (int i = 1; i <= noOfColumns; i++) {
			tableContents.append(metaData.getColumnName(i) + " \t ");

		int sbLength = tableContents.length();
		for (int i = 0; i < sbLength; i++)

		while ( {
			for (int i = 1; i <= noOfColumns; i++) {
				tableContents.append(resultSet.getString(i) + " \t ");

		if (tableContents.length() == 0)
			tableContents.append("No data found");



Run the program with the db2jcc.jar file in the classpath, as shown below:

$ java -cp /opt/ibm/db2/V9.7/java/db2jcc.jar:. PrintSQLTable
1 	 abdullah 	

List of Shortcuts for the Eclipse Java IDE

Here’s a cheat sheet of Eclipse shortcuts I’ve put together to help me work really fast with the IDE. The shortcuts have been categorized into two sections – one that most people know about, and another section that contains the lesser known ones. You should be able quickly scan through the first section, and learn any of the ones that you don’t currently know.

The second section might take longer, and you may want to bookmark this page for future reference.

Easy Shortcuts

Search in files

Use CtrlH to search in all files across the workspace or project.

Search Dialog in Eclipse Juno

Open Resource

CtrlShiftR opens a resource quickly – without the time it spends for indexing. This makes it especially fast when you’ve just opened a workspace, in comparison to the Open Type shortcut below.

Open Resource Dialog in Eclipse Juno

Open Type

Use CtrlShiftT to open a Java type.

Open Type Dialog in Eclipse Juno

While I prefer CtrlShiftR to search for files, CtrlShiftT works better if you want to search for Java classes or interfaces.

Open the Type Hierarchy

Use CtrlT to get a popup window with the type hierarchy for the type under your cursor.

Type hierarchy popup - Eclipse Juno

This is tremendously useful to see inherited types, sub-types, and implemented interfaces.

Press CtrlT again to toggle between super-types and sub-types.

Display members and inherited members

Pressing CtrlO displays the class members, pressing it again displays the inherited members too!

Eclipse class members popup

Focusing on the tooltip

Press F2 to get the tooltip for the item currently under the cursor.

F2 Tooltip Eclipse Juno

Correcting Indentation of Selected Text

Use CtrlI to correct indentation.


Use F5 to Step into, F6 to Step over, F7 to step out, and F8 to resume. See below for more shortcuts on debugging.

New File Wizard

Use CtrlN to start the new File Wizard.

New File Wizard - Eclipse Juno

Lesser Known Shortcuts

CtrlTab to Switch Between Windows

Go to General->Keys to see all shortcuts.

Setting Eclipse Juno shortcut for switching between editor windows

Change the binding of Next Editor and Previous Editor to use Tab instead of F6 – this makes it incredibly easy to switch between open editors. I often dislike changing keyboard shortcuts so that it’s easy to work on someone else’s machine too, but I couldn’t resist this one.

Cycle through tabs in the current view

Similar to the above, but still slightly different: Use CtrlPgUp and CtrlPgDn to switch between tabs in your current viewwithout showing you the complete list of available tabs.

Scroll without using the mouse

Use CtrlUp and CtrlDown to scroll, while keeping your cursor in the same position!

Move a line or lines

Use AltUp and AltDown to move selected lines, or the current line.

Jump to matching bracket

CtrlShiftP on a bracket, brace or parenthesis moves the cursor to its matching bracket, brace or parenthesis.

Progressively Select Blocks

Use ShiftAltUp / ShiftAltDown to progressive select blocks.

Find references

CtrlShiftG will find references to the item under the cursor.

Find declarations (Only C++/Javascript)

CtrlG finds declarations of the item under the cursor.

Open Declaration

F3 opens the declaration for the item under the cursor.

Find previous and next, based on selection

Use ShiftCtrlK and CtrlK to find the previous and next occurrences of the item under the cursor.

I had to set CtrlK for “Find next” in Preferences->General->Keys, but the shortcut for “Find previous” was there by default.

CamelCase Code Completion

If you have a class that has a VeryLongName, simply type VLN and press CtrlSpace to see VeryLongName as one of the suggestions.

Automatically Insert Braces and Semicolons at the correct position

This isn’t a shortcut – but a useful productivity boost. Setting semicolons and braces to be automatically inserted in the correct position allows you to type them in from anywhere but they actually appear at the end of the line. Escaping text in string literals is another useful option.

Eclipse Juno preferences - automatic insertion of braces and semicolons at correct position and escaping pasted strings

Quick Access Menu

Quickly access any menu, command, editor, etc by typing in Ctrl3 and then the initial letters of the item you want.

Eclipse Juno quick access menu


Use AltLeft and AltRight to navigate between your editor history items. This is equivalent to using the history icons on the toolbar.

Eclipse Juno history toolbar buttons

Quick Fix

Use Ctrl1 to get to the quick fix menu and quickly fix compile-time issues.

Eclipse Ctrl-1 quick fix menu


Use CtrlR to run to the current line. Use CtrlShiftB to toggle a breakpoint. F11 debugs the last run program, while CtrlF11 runs it.


ShiftAltR renames an item and updates all references. Use ShiftAltL to extract code to a local variable, and ShiftAltM to move code to a method.

The Best of them all!

And finally, which one’s the greatest shortcut of all? Use CtrlShiftL to get a list of all available shortcuts!!

Eclipse Juno list of shortcuts


Reflection Proofing the Java Singleton Pattern when using Lazy Loading

The singleton design pattern in Java is one that I found over the years to be both tricky and interesting. There are many ways to break this pattern – and developers keep writing about different techniques to break it. One powerful way to break this pattern is to use reflection to access the private constructor and instantiate the class as many times as you want. The underlying idea is that you can call private members of any class using theAccessibleObject.setAccessible(true) reflection method.

There are available techniques to prevent such reflection attacks. One of them is using the old way of writing your Singleton class, that is, not using lazy initialization, and, in addition to that, throwing an exception in the constructor if it’s asked to create a second instance. Any client attempting to illegally execute the constructor after an instance is created will be thrown an exception. Listing 1 below illustrates this:

Listing 1: JavaSingleton class

package server;

public class JavaSingleton {
  private static final JavaSingleton INSTANCE = new JavaSingleton();
  private JavaSingleton() {
    if (INSTANCE != null) {
      throw new IllegalStateException("Inside JavaSingleton(): JavaSingleton " +
                                                        "instance already created.");
    System.out.println("Inside JavaSingleton(): Singleton instance is being created.");
  public static final JavaSingleton getInstance() {
    return INSTANCE;

Listing 2: JavaSingleton client

import server.JavaSingleton;
import java.lang.reflect.*;

public class TestSingleton {
  public static void main(String[] args) throws ReflectiveOperationException {
    System.out.println("Inside main(): Getting the singleton instance using getInstance()...");
    JavaSingleton s = JavaSingleton.getInstance();

    System.out.println("Inside main(): Trying to use reflection to get another instance...");
    Class<JavaSingleton> clazz = JavaSingleton.class;
    Constructor<JavaSingleton> cons = clazz.getDeclaredConstructor();
    JavaSingleton s2 = cons.newInstance();


When you run this client, you will get following output:

C:\singleton>java TestSingleton
Inside main(): Getting the singleton instance using getInstance()...
Inside JavaSingleton(): Singleton instance is being created.
Inside main(): Trying to use reflection to get another instance...
Exception in thread "main" java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at TestSingleton.main(
Caused by: java.lang.IllegalStateException: Inside JavaSingleton(): JavaSingleton instance already created.
  at server.JavaSingleton.<init>(
  ... 5 more

Nice stuff! But there’s one that noticeable here. This technique is possible only with early initialization, and not while using lazy initialization.

Lazy initialization, also known as on demand initialization, is often a requirement for reducing start up time of an application.

I wanted to write a singleton that addresses both the requirements of lazy initialization and defending against an attack in which a client creates a second a instance of the singleton.

My knowledge of Java Security gained while working on Websphere came in handy.

A Possible Use Case for this Requirement

Suppose we have a Java based service, in which clients get an instance via the getInstance() method, and we’d like to protect against multiple instances being created to avoid concurrency or memory related issues. Also, the start-up time needs to be short, so the method described above won’t work. The reason is that if we are throwing an exception in the constructor, we’d need to be certain that the first call to the constructor comes from within the class, or else the single instance could belong to a wrong class.

Design for the Reflection-Proof Lazily Initialized Singleton

  1. Allow ONLY the same class to access the constructor: We’ll need to do two things for this:
    1. Add code in the constructor that checks to see if the caller has access
    2. Create a policy file that defines which callers have access.
  2. There is one more thing, however. The Java Security Mechanism will check for the caller permissions for all callers present in the entire stack trace. Because of this, we need to wrap the call to our constructor in a doPrivleged block so that permissions are checked only from that point itself.

Modified Code for Lazy Initialization and Reflection Access Checks

Listing 3: Server JavaSingleton class

package server;

import java.lang.reflect.ReflectPermission;

public class JavaSingleton {

  private static JavaSingleton INSTANCE = null;
  private static int count = 0;

  private JavaSingleton() {
    ReflectPermission perm = new ReflectPermission("suppressAccessChecks", "");
    System.out.println("Singleton Constructor Running. Instance #" + count);

  synchronized public static final JavaSingleton getInstance() {
    if (INSTANCE == null) {
      AccessController.doPrivileged(new PrivilegedAction<Object>() {
        public Object run() {
          INSTANCE= new JavaSingleton();
          return null;
    return INSTANCE;

}//end of class

Listing 4: Client class

import java.lang.reflect.*;
import server.JavaSingleton;
public class TestSingleton {

  public static void main(String[] args) throws ReflectiveOperationException {
    System.out.println("Using getInstance...");
    JavaSingleton s = JavaSingleton.getInstance();

    System.out.println("Trying to use reflection to instantiate Java Singleton...");
    Class<JavaSingleton> clazz = JavaSingleton.class;
    Constructor<JavaSingleton> cons = clazz.getDeclaredConstructor();
    JavaSingleton s2 = cons.newInstance();      
  }//end of main

}//end of class

Policy File Changes and Invocation

Creating a policy file

  1. Start the policy tool present in your JDK bin folder, and click “Add Policy Entry”Policy tool - first screen
  2. Enter the path to your Singleton class in the code base, the format of a URL. Do not include the package folder, and make sure your client classes reside in a different folder. For example, “file:/C:/singleton/server_code/”.CodeBase in policy tool
  3. Click “Add Permission” and select ReflectPermission from the Permission drop down and then select suppressAccessChecks from the Target Name drop down, and click OK.Permission added in policy tool for supressAccessChecks
  4. Click DonePolicy tool after adding permission
  5. Click File->Save, and provide a file name like

Your file should look similar to the following:

/* AUTOMATICALLY GENERATED ON Sun Nov 06 22:05:42 AST 2011*/

grant codeBase "file:/C:/singleton/server_code/" {
  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";

Important: Keep the client and server code in separate code bases, otherwise the client code will have reflective access to the server code that it shouldn’t have. I placed the client class file in C:/singleton, and the server class files in C:/singleton/server_code. That is, the two server class files were present in C:/singleton/server_code/server (since they are in the “server” package).

Invoking the program

Invoke the program using a VM arg that specifies the location of the policy file:

C:\singleton>java  -cp .;server_code TestSingleton
Using getInstance...
Singleton Constructor Running. Instance #1
Trying to use reflection to instantiate Java Singleton...
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at TestSingleton.main(
Caused by: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
        at Source)
        at Source)
        at server.JavaSingleton.<init>(
        ... 5 more

Looking at the above output, we can see that our malicious client was denied access when trying to call the constructor directly. Thus, this example illustrates how we can implement a singleton that uses lazy initialization and protects against reflective attacks.



Upgrade from Ubuntu 11.04 to 11.10, and a pleasant user interface greets you. Does the good news end there?

UPDATE (18th Nov, 2011): I carried out a clean installation from a USB drive, and no longer have the purple/blank screen problem while loading the 3.0.0-12-generic kernel. I can conclude that a problematic web upgrade process prevented the newer kernel from loading. Possible fixes are being discussed on various forums, but none of them have worked for me.

I’ve been running Ubuntu 11.04 (Natty Narwhal) for several months and have been satisfied with the experience. In October 2011, the newest stable Ubuntu 11.10 version (Oneiric Ocelot) was announced.

The upgrade to the new distro can be carried out by running the command:

sudo do-release-upgrade

You could also enable automatic updates, like I did, and have Natty Narwhal prompt you to upgrade. Simply go to System -> Administration -> Update Manager, click on the ‘Settings…’ button, and in the ‘Updates’ tab, turn on the checkbox for automatic updates. Also ensure that the release upgrade option is set to “Normal releases”.

To me, it was a surprise that I didn’t have to go to fetch Ubuntu 11.10 or run a command to get it – it came straight to me!

Welcome to Ubuntu 11.10 Oneiric Ocelot

Fast and easy install? Well, the upgrade certainly did not go on unattended and repeatedly questioned me about replacing some old configuration files.

My machine, incidentally, isn’t so dated – it runs an AMD Athlon X2 2.5 GHz processor with 2 GB RAM and an Nvidia GeForce7050PV graphics card.

After a lengthy download of over 850 MB – the size may vary for you, depending on the number of packages needed – and an install process which wasn’t without hiccups, I had to restart, only to find a blank purple screen and no hard disk activity.

Enough to cause my heart to sink.

Doing a hard reboot took me to a menu with a list of options to choose from:

  1. Ubuntu, with Linux 3.0.0-12-generic
  2. Ubuntu, with Linux 3.0.0-12-generic (recovery mode)
  3. Previous Linux versions
  4. Memory test (memtest86+)
  5. Memory test (memtest86+, serial console 115200)

If I’d choose the first option, I’d be back to square one. Choosing the second option would result in a kernel panic.

I went to “Previous Linux versions” and found these options:

  1. Ubuntu, with Linux 2.6.38-8-generic
  2. Ubuntu, with Linux 2.6.38-8-generic (recovery mode)

I chose the first one and was greeted by a glossy LightDM login screen, followed by a beautiful new Ubuntu desktop.

An Exciting New Linux – But not everything’s Smooth Sailing

It turned out that Ubuntu 11.10 was failing to load the new Linux 3.0.0-12-generic kernel. I decided to install the startup manager from the synaptic package manager, and set the default operating system to the older Linux 2.6.38-8-generic to allow my system to function.

Startup Manager

A big thank you to the posters discussing this issue on the thread that helped me!

As for the user interface, much of it is revamped. The action of dragging and docking folders is nicely animated. My Atheros chip based Wi-Fi adapter now connects me to the Internet almost instantly, unlike the case with Natty Narwhal, where I had to wait for several tens of seconds before connectivity would be established. The processes of both starting up and shutting down the computer take only slightly longer.

There’s a prominent launcher that appears when hovering the cursor on the left side of the screen, to help you open your favorite application almost instantly.

Clicking the dash on the top-left corner reveals a translucent box to help navigate to various parts of your machine fairly fast. There’s a Mac OSX-style spotlight for instant searches. However, critics are furious that Ubuntu is trying a lame copy of Mac’s stunning user interface and falling short.

Accessing the most frequently used and other installed applications through the dash was never easier, not least due to the Filters feature that is clearly a leap over the basic offerings of Ubuntu 11.04.

Ubuntu 11.10 Desktop

What worries me is that the dash once became unstable and disappeared.

Switching applications is facilitated by pressing either the Alt+Tab or Alt+Grave buttons and choosing a running program from a frosted-glass box. However, this seems to cause my computer to hang after using it for several seconds, calling for a hard reboot.

I haven’t really tried many of the applications that came pre-bundled with Ubuntu 11.04 or were available for download, since I spend most of my time on the Internet. The few I did try from the math, engineering and graphic designing sections failed to impress me, and I won’t be surprised if Ubuntu 11.10 is not very different on this front.

The Conclusion?

Well, there still seem to be issues that Canonical has to address. Ubuntu 11.10 with its default Unity interface surely has an unprecedented, elegant look and feel. But there’s got to be more than skin-deep beauty – Canonical should definitely have done better testing on the upgrade process and its end result.

How to enable Java in Chrome and Firefox on Ubuntu

To enable Oracle’s Java plugin in your Linux browsers, just copy these lines into a script, and run it!

mkdir $MOZILLA_HOME/plugins
ln -s $JAVA_HOME/jre/lib/i386/ $MOZILLA_HOME/plugins

Note: You may need to change the value of JAVA_HOME so that it correctly points to your installation of the JDK. 64-bit users will need to change the final line to:
ln -s $JAVA_HOME/jre/lib/amd64/ $MOZILLA_HOME/plugins

If you’re a newbie, here’s how to run the script:

  1. Using your favorite editor, paste the contents of the script into a new file.
  2. Find out where Oracle Java is installed. This location has the directories “bin”, “lib”, and “jre”, among others. Replace the value of JAVA_HOME with the path to this folder, and save the file. This step applies if you’re using the JDK. If you’re only using the JRE, let JAVA_HOME point to the jre installation directory (which contains the folders “bin”, “lib” and “plugin”), and modify the last line in the script to remove “jre” from the path.
  3. Make the script executable, by typing in chmod +x <filename>
  4. Run the script using the command ./<filename>
  5. Restart your browser, and confirm your installation as shown in the next section

The above script will enable Java support in both Chrome/Chromium and Firefox, since they both use the ~/.mozilla/plugins directory to scan for available plugins.

Confirming Installation

After you’ve restarted your browser, if you see a message below detailing your installed Java version and operating system, you’ll know it’s working successfully.

You can also look up the address “about:plugins” in Chrome or Firefox to get the list of plugins installed in your browser.

Alternatively, look up Oracle’s How do I test whether Java is working on my computer? to confirm the version of Java your browser is using.


If you’re facing problems with your Java plugin not working correctly on certain sites, you might want to try updating Java to the latest version. Also, you could try switching to Oracle’s version (in case you’re running the OpenJRE or IBM’s JRE), since that’s what’s best supported on the web.

Attacking a Weird Java Error: java.lang.ClassFormatError: Invalid pc in line number table

While working on the Oracle Application Framework, my Application module’s class file was behaving in a strange manner. When it was deployed on Apache and run, it was throwing the following Error:

oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.ClassFormatError, msg=oracle/apps/fnd/framework/test/updateAMImpl (Invalid pc in line number table)
at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(
at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(
at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(
at oracle.apps.fnd.framework.webui.OAHttpSessionCookieImpl.useApplicationModule(
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(

I Googled on this error a lot, but most of the suggested solutions spoke about compiling the class with a different JDK or a different Java version and deploying it again. I tried to do that, but the error persisted.

Decompiling using javap

I thought of decompiling the deployed class using the javap utility – if it would fail to decompile, that would surely indicate a problem with the class itself. However, javap decompiled it correctly, and correctly displayed public methods of the class.

I glanced through the help of javap (using -help), trying to figure out how to get a peek at the private methods too. While doing that, I noticed an interesting option: -verbose. This disassembles the code, and also prints the stack and line number table. Intrigued, I tried to run:

D:\JDeveloper\jdevhome\jdev\myclasses>javap -verbose oracle.apps.fnd.framework.test.UploadAMImpl > detailedclassUploadAMImpl

and it displayed the following (for the sake of brevity, I’ve pasted only relevant sections):

 170: invokestatic #92; //Method oracle/apps/fnd/framework/OAException.wrapperException:(Ljava/lang/Exception;)Loracle/apps/fnd/framework/OAException;
 173: athrow
 174: astore 11
 176: jsr 182
 179: aload 11
 181: athrow
 182: astore 12
 184: iload 7
 186: invokestatic #88; //Method java/lang/String.valueOf:(I)Ljava/lang/String;
 189: astore 8
 191: aload 8
 193: areturn
Exception table:
    from    to    target    type
   77   148   154   Class java/sql/SQLException

156 163 166 Class java/lang/Exception

77 174 174 any LineNumberTable: line 150: 0 line 151: 8 line 152: 14 line 153: 39 line 154: 58 line 155: 70 line 156: 73 line 158: 77 line 159: 86 line 160: 95 line 161: 104 line 162: 112 line 163: 122 line 164: 141 line 165: 154 line 167: 156 line 168: 166 line 169: 168 line 170: 174 line 171: 184 line 172: 191 line 174: 193 line 173: 194

Looking at the line number table and disassembled code, I didn’t get anything conclusive. Then I just tried the same stuff on another class which was not having the same problem:

D:\JDeveloper\jdevhome\jdev\myclasses>javap -verbose oracle.apps.fnd.framework.test.webui.testEmpCO
 > CODetailed

which gave me following output (again pasting relevant sections for sake of brevity)

 433: invokeinterface #28, 2; //InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
 438: checkcast #29; //class String
 441: astore 10
 443: aconst_null
 444: aload 9
 446: if_acmpeq 461
 449: aload_0
 450: aload_1
 451: aload_3
 452: aload 9
 454: aload 10
 456: aload 5
 458: invokespecial #79; //Method _triggerProcess:(Loracle/apps/fnd/framework/webui/OAPageContext;Loracle/apps/fnd/framework/OAApplicationModule;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
  461: return
 Exception table:
    from    to    target    type
    223    324    327    Class oracle/apps/fnd/framework/OAException

LineNumberTable: line 138: 0 line 140: 8 line 141: 14 line 142: 26 line 144: 34 line 145: 42 line 147: 52 line 148: 58 line 149: 73 line 150: 88 line 152: 107 line 153: 122 line 155: 133 line 156: 152 line 157: 171 line 158: 187 line 159: 206 line 161: 212 line 167: 223 line 168: 245 line 170: 254 line 171: 259 line 173: 274 line 175: 286 line 177: 300 line 178: 305 line 180: 316 line 185: 327 line 187: 329 line 188: 337 line 190: 346 line 191: 362 line 192: 375 line 193: 383 line 194: 391 line 196: 397 line 200: 411 line 201: 427 line 202: 443 line 203: 449 line 213: 461

I tried to compare the verbose output of both. Though I couldn’t make much out of it, I noticed one thing: for correct class (testEmpCO), the last line number in line number table (line 213: 461) against the last assembly instruction was same as the last line number of the disassembled code.(461: return)

However, for the class which had the error (UploadAMImpl), the last line in the line number table was 194 (line 173: 194). However the last line number for disassembled code was 193 (193: areturn). I became curious and checked the last assembly instruction which was starting at line 173 (pasted again below):

 170: invokestatic #92; //Method oracle/apps/fnd/framework/OAException.wrapperException:(Ljava/lang/Exception;)Loracle/apps/fnd/framework/OAException;
 173: athrow

Though I couldn’t decipher it completely, I could make out from instructions that it was something related to OAWrapperException, which was present in my code.

I decided to replace the same with OAException which is the normally followed practice instead of OAWrapperException, which I had copied from Fwk developer’s guide. After doing the change, I ran again

D:\JDeveloper\jdevhome\jdev\myclasses>javap -verbose oracle.apps.fnd.framework.test.UploadAMImpl >

and the following was the output:

 195: invokespecial #32; //Method oracle/apps/fnd/framework/OAException."":(Ljava/lang/String;B)V
 198: athrow
 199: return
 Exception table:
    from    to    target    type
	   13    178    181    Class java/lang/Exception

LineNumberTable: line 106: 0 line 107: 8 line 109: 13 line 110: 20 line 112: 27 line 113: 43 line 114: 59 line 115: 74 line 116: 85 line 117: 104 line 118: 114 line 119: 130 line 120: 146 line 121: 162 line 123: 181 line 124: 182 line 125: 186 line 127: 199

Now, last line number in line number table 199 (line 127: 199) was matching with last line number of disassembled code ( 199: return). I hoped by now that this should work and after deploying, it really worked !!!!

I don’t know what was causing OAWrapperException to cause this issue , but I thought I would share this technique as this is generic error and it can be encountered by any java programmer. This is rare error and that is why it is difficult to address, as not lot of practical help is available on this and programmers can learn to unleash the power of javap and its various options.

I hope the technique I’ve described above will be handy for programmers who come across this kind of error.

Our guest writer, Vishal Chougule, is an avid Java developer and a technology lover. His interests range from computer security to design patterns.

A Quick Tutorial to Set Up an NFS Server on Windows

Update (Nov 9, 2011): As noted in the comments below, Windows Services for UNIX Version (SFU) is no longer supported on Windows 7 and 2008. For these versions, try installing Cygwin with the optional nfs-server component. If you’re using Windows 2008, you can use the Server for NFS that comes built-in instead – in this case, most of the steps below should apply.

A few days ago, I needed to share a large folder present on a Windows server to access it from my local Ubuntu workstation. I initially used Samba, but my build script refused to recognize paths present in that share.

The solution was to use an NFS share – but this required a special setup on Windows. Even after a lot of searching on Google, I couldn’t easily find a guide that talked about how to get started with an NFS server on Windows quickly. Most articles I came across were only detailing information on NFS security, or some obscure command line options for tweaking NFS options – which shouldn’t be required when all you want is a simple share within your local, protected network.

So, here’s what to need to do if you need an NFS server enabled on Windows quickly, and mount it on your Linux box:

1) Download Windows Services for UNIX from Microsoft’s Download Center. Here’s the direct download link.

2) Run setup.exe from the extracted directory.

Welcome to the Microsoft Windows Services for UNIX Setup Wizard

3) Follow the prompts, until you reach the following screen:

Installation Options

Choose custom installation – since we’d like to only install the NFS server for sharing folders.

4) Choose the following three components to install:
(i) NFS -> Server for NFS
(ii) Authentication tools for NFS -> User Name Mapping
(iii) Authentication tools for NFS -> Server for NFS Authentication

Here’s a pictorial representation of the components you’ll need:

Selecting Components   Selecting Components

5) On the next screen, choose to change the behavior to case-sensitive, to provide full compatibility with UNIX programs

6) On the User Name Mapping screen, choose “Local User Name Mapping Server” and “Password and group files”:

User Name Mapping

7) Now, copy your passwd and group files from your UNIX/Linux distribution onto your Windows machine. For Ubuntu, these are located at /etc/passwd and /etc/group. Provide the paths to these files in the next screen:

User Name Mapping Configuration

8) Continue with the installation prompts until you finish.


9) Windows Services for UNIX should now be installed:

Windows -> All Programs

10) Open the Services for UNIX Administration shortcut, and click on User Name Mapping:

User Name Mapping on local computer

11) Click on “Show User Maps” and then click on the buttons for Listing Windows Users and Linux Users:

Creating a map

12) Choose “Administrator” (or the appropriate account you want to map the UNIX user to) in the Windows list, and your username in the Linux list. (In Ubuntu, UIDs for user accounts usually start from 1000)

13) Click “Add” to create a map. If you get the following warning, click “OK” to ignore it.

You have specified a special Windows account.

14) Click Apply at the top right corner.

15) Now, you’re ready to share folders! Just right click any folder you need to share, and share it from the NFS tab. You can click the Permissions button for more options, like allowing write access, which is disallowed by default.

NFS Sharing on Windows.

16) Next, mount the share on your UNIX/Linux machine. I used the following command on Ubuntu:

$ sudo mount <windows-server-ip-address>:/<windows_share_name> <path_to_local_mount_point>

For example:

$ sudo mount ~/windows_share

If this guide helped you, please let us know in the comments below!

Automatic Login For SSH/SFTP on Ubuntu

There are just three simple steps needed to automate your SSH/SFTP logins to remote Unix/Unix-like servers from your Ubuntu/Linux distribution, or an emulator on Windows like Cygwin.

1) Run ssh-keygen

abdullah@desktop:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/abdullah/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/abdullah/.ssh/id_rsa.
Your public key has been saved in /home/abdullah/.ssh/
The key fingerprint is:
06:23:fc:34:0f:12:40:b2:5e:7c:41:eb:4f:a2:ab:24 abdullah@desktop
The key's randomart image is:

Randomart image

2) Run ssh-copy-id <username>@<server-name>

abdullah@desktop:~$ ssh-copy-id's password: 
Now try logging into the machine, with "ssh ''", and check in:


to make sure we haven't added extra keys that you weren't expecting.

3) Login to your server using ssh

abdullah@desktop:~$ ssh ''
Welcome to!
Last login: Sun Sep 25 23:22:21 2011 from 

That’s all!

If you want a quick shortcut in the GUI, you could add a Custom Application Launcher to the panel with the ssh login command, as shown below:

Launcher Properties

Clicking the panel icon will directly open the terminal at the server with you logged in.

Note that this will also automate the login for SFTP, so you won’t need to type in your passwords there anymore too!

How to Delete a Directory in Linux

To delete or remove a directory in Linux, use the “-r” flag to the “rm” command. “r” stands for recursive.

rm -r <directory_name>

On some Linux systems, you might be prompted before each file is deleted. This means that the rm command has been aliased to “rm -i”, which turns on interactive mode. To run the original rm command and avoid the prompts, use “\rm”:

\rm -r <directory_name>

In the bash shell, just as the backslash is used to escape special characters, it is also used to escape aliases.


Be careful to double check the directory name you provide, and be extra careful when using wildcards. There have been many stories of grief because of users ending up deleting important files and folders recursively.

Flipkart – An Amazing Online Shopping Experience

Flipkart is often called the Amazon of India. Set up by two ex-Amazon employees as a startup in 2007, it brings Indians the best of the online shopping world knocking at their doors.

I’ve been a regular buyer of stuff from Flipkart, and my experience with them has been simply amazing. So here’s my review on Flipkart, and what I believe has been helping them to be highly successful.

1) They provide an estimated delivery time – and keep their promises

Flipkart does not think short term by providing overly optimistic delivery times. Online stores will ensure returning customers only if they keep their promises, and Flipkart seems to keep that in mind with their fairly accurate delivery time estimates.

The promised time of delivery varies between a few days to a couple of weeks, depending on the availability of the goods. Generally, items arrive well within the time frames.

Only once out of a dozen-odd orders I experienced a delay of ten days. I’d overlook that as an exception.

2) Dead low prices

The prices are among the lowest I could find in shops around, and Flipkart doesn’t charge for delivery. If you consider the traveling cost for going to the cheapest shops around, Flipkart will probably end up being cheaper. What attracts buyers more than the best deal in terms of money?

UPDATE (Feb 26, 2012): This no longer seems to be true. Prices have been rising, and they even delete reviews that talk about the rising prices. Flipkart explicitly warns that they may remove any pricing related comments.

3) They have their own courier services

This was a pleasant surprise to me when I first ordered from them. Flipkart uses their own courier system, to do away with the problems rampant with the infamous courier services in India.

4) Insured protection for electronic items

There have been many stories about courier delivery guys opening up packages to steal goods. Flipkart has taken the initiative to guide you upfront on this – they have insured shipping for electronic goods, so check your package when you receive it, and ask for a replacement if it’s tampered with. Hopefully, such instances won’t happen with Flipkart’s delivery service.

5) Varied options for payment – including cash on delivery

For a smoother buying experience, there are many options for payment – Credit/Debit cards, Net Banking, and Cash on Delivery in select cities. The last option is interesting – many Indian buyers are skeptical of buying items online because of the prevalence of fraud. Delivering the product home before it’s paid for is a great way to build customer confidence.

As a bookstore and a general shopping site, Flipkart seems to have a great future ahead and is already gaining a good name among the masses.

Have you ordered goods from Flipkart? Are you skeptical about online shopping in India? Feel free to comment below!