Installing Oracle 10.2 on Suse Linux 10.2

When installing Oracle 10.2.0.1 client on Suse Linux 10.2, the installation fails with message -

Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2 Failed <<<<

To complete the install, run installer as ./runInstaller -ignoreSysPrereqs
(installation-oracle-on-suse-linux-enterprise-10)

To run Tora, add the following to your profile file

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

And create a tnsnames.ora file in your ORACLE_HOME.
This file lists your Oracle services in the following format -

XE_192.168.1.1=

    (DESCRIPTION =

       (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521)))

       (CONNECT_DATA = (SID = xe) (SERVER = DEDICATED))

    )

(Re: Error connecting to an Oracle DB)

If Tora is still not connecting to oracle, try exporting TNS_ADMIN environment variable, pointing to the location of tnsnames.ora file -

export TNS_ADMIN=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/

Are you smart enough to quit your job?

Thanks to Erik’s Linkblog, I came across one of the best blog posts I have read recently.

Paul Tyma, a senior engineer at Google, talks about Software Engineering interviews. Something he said, really struck a chord with me -

if you are the smartest person at where you work – QUIT

I came across the same idea while reading Paul Graham some time ago. He mentions the talk You and Your Research by Richard Hamming. In Paul Graham’s words, ask yourself these three questions -

  1. What are the most important problems in your field?
  2. Are you working on one of them?
  3. Why not?

These are the questions that can change your life.

I have been thinking about switching to a four day work week, so I can spend at least a couple of days a week working on more challenging and interesting problems. And today, I feel I am ready to make that move.

I see happier times ahead :)

Spring MVC – How to access the command object in referenceData method

One thing that I really like about Spring MVC is that if you need a particular method, and you make a reasonable guess where to look for it, you will find it. That is, in fact, a lot like core Java APIs.

I needed a reference to the current form backing object to set up the reference data for the form being displayed. Now, most of Spring tutorials, books etc. only mention the referenceData(request) method that takes a single HttpServletRequest object as parameter, and that was the only one I knew about. So, I was planning to look up the details of the Spring MVC form workflow, but did the usual googling for anyone else running into this method.

And what do I find? A method that does exactly what I needed :)

If your referenceData method depends on the command object, this is what you use -

referenceData(PortletRequest request,
Object command, Errors errors)

Stringtree – Simple JSON in Java

If you are like me, you probabely find that most of the Java implementations of JSON are rather bloated, especially for simple uses of JSON. Most of the time, I only need to convert a simple map to JSON, which I do using a simple class I had written

Some time ago, I came accross a very simple implementation of JSON-Java converstion. See Stringtree JSON .

It is a nice, simple implementation consisting of all of 2 classes. I have only used the JSONReader class so far, and it seems to do its job well.

I had to make a few changes to fix a couple of issues, though. In case anybody runs into the same issues, here are my changes (in all their Unified Diff glory :) ) -

Bugfix for infinite loop if a value is null, true or false -
@@ -81,13 +81,17 @@
} else if (c == 't' && next() == 'r' && next() == 'u' && next() == 'e') {
ret = Boolean.TRUE;
+ next();
} else if (c == 'f' && next() == 'a' && next() == 'l' && next() == 's' && next() == 'e') {
ret = Boolean.FALSE;
+ next();
} else if (c == 'n' && next() == 'u' && next() == 'l' && next() == 'l') {
ret = null;
+ next();
} else if (Character.isDigit(c) || c == '-') {
ret = number();
}

- System.out.println(“token: ” + ret); // enable this line to see the token stream
+// System.out.println(“token: ” + ret); // enable this line to see the token stream
+
token = ret;
return ret;

In JSONWriter. To fix the null pointer error, if the field has no getter or is inaccessible otherwise -

String name = prop.getName();
Method accessor = prop.getReadMethod();
- Object value = accessor.invoke(object, (Object[])null);
- add(name, value);
+ if(accessor != null) {
+ Object value = accessor.invoke(object, (Object[])null);
+ add(name, value);
+ }

Making Auto-Login user script work on Flock

I use the Auto-Login user script at http://labs.beffa.org/greasemonkey/ to ease some of the pain of JEE development.

Recently, I decided to try out Flock for a few days, and the script didn’t work with it.

Thanks to Dive Into Greasemonkey, here is a quick fix.

This part of the script fails when running on Flock browser -

//to prevent submit to stupid site which put fake login / pass value
if (thisElement.value != thisElement.defaultValue) {
passfield = true;
thisElement.addEventListener(&acirc;€™keypress&acirc;€™, al_KeyPress, true);
}

For some reason, thisElement.value is always empty on Flock. On Firefox, it shows the actual value of the field.
Anyway, since I only use this script to login into a particular web page, I removed that if condition, and it works fine.

Type conversion when using the ternary operator

What is the type of val in the following code?

boolean asInt = true;
Object val = asInt? 5 : 5.0;

If you guessed Integer, guess again. :)

JLS states -

if the second and third operands have numeric type, …. binary numeric promotion is applied to the operand types, and the type of the conditional expression is the promoted type of the second and third operands.

If the second and third operands are of different reference types, then it must be possible to convert one of the types to the other type (call this latter type T) by assignment conversion ; the type of the conditional expression is T.

(Ref – JLS 15.25 Conditional Operator ? : )

I am sure I would have come across this while studying for my SCJP exam, but in real life, you rarely have objects of different types being returned from a ternary operator, so this can really catch you unguarded.

With an If-Else block, things work out as expected -

boolean asInt = true;
Object val = asInt? 5 : 5.0;
System.out.println("val is - " + val + " : " + val.getClass());
if (asInt) val = 5;
else val = 5.0;
System.out.println("val is - " + val + " : " + val.getClass());