Tuesday, October 12, 2004

Weblogic and the curse of the Session Id
While implementing a simple session time out scenario , i encountered problems which seemed bizarre .. i discovered that multiple sessions being created .Strangely i saw that these sessions were being created even though an existing session was in place .and clicking any link on the site created a new session almost everytime . Deciding to do something different i entered the url on the browser and voila !! no sessions were being created ... Further investigation led me to the weblogic.xml which had an encode sessionidinquery params value set to true . What this triggered was the weblogic now only understood if there was jsessionId present in the browser .and the web site did'nt use any of the response.encodeUrl() so clicking on any link on the website resulted in creating a new session.

Changing the parameter encodeSessionIdinQueryParams to false restored some sanity and able to carryout the timeout implementation.


Monday, October 11, 2004

The Phantom data trail

For those who have come in late ..
We were happy to use the connection pool for database access . just get the connection from the pool use it and release it back... life's cool until one day when we decided to execute a transaction . we followed the following steps ...
  1. get a connection from the free pool
  2. set the connection's auto commit property to false (needed for a transaction
  3. put the db execute/update statements within a try catch block
  4. In the catch block log the exception and,close the statement release the connection and throw the exception back
  5. end of the method con.commit()
  6. release the connection back to the pool

This worked pretty much fine for all the happy flows ... whenever an error happened we used to have some data appearing in the database long time after the operation was over .The mystery further deepened when we found out this data which was appearing was due to failed transaction.

Reality dawned a li'l later when I found out that in the catch block one crucial step was missing conn.rollback() w/o which we used to release it to the pool and when someone else gets this same connection and performs certain other operations along with those operations whatever statements were successful in the previous operations were being updated

Moral of the story

pool or no pool ... to keep life a li'l simpler and easier follow the best practices


Thursday, September 16, 2004

KISS

bigg problems simple solutions ..It took me 2 days and 6 hours later to learn this lesson.The issue was with the deployment , things were going smoothly while coding and problems started when we tried to deploy the application. Initially found some abandoned jars in the lib folder , it took us a while to ensure that this was not needed as we removed them we found out certain entries made in xml files were redundant , the classes corressponding no longer there .. from here it was road to hell .. missing files, wrong config issues and we had almost made it when we encountered the dreaded 404 error ...everything seemed fine the path the jsps were all in place .. and in the end we tracked it to the webserver which was not configured for jsps ... does sound crazy ... we fixed that and found a similar symptom for the css, htm, java script files ... it was about this time that we got the app deployed

a lesson learnt Keep It Simple Stupid !!

Tuesday, August 24, 2004

What say folks ?

Imagine a software application written without proper error handling mechanism. guess how wud the maintenance be ..ask me ?? i had a pretty torrid time setting up the application last week and struggled for more than a couple of hours with a classic classpath problem. I just cant stress the importance of having the correct set of classes in the source control..What more ,In case if some thing goes wrong show the user a blank page to test how vivid his imagination can be ...had a pretty frustrating time with the setup it took more effort than my coding ...finally was able to get it up and running after some hours of SOP and commenting of the code found that the logger part was not working ...so the application is not working ...yup u would read it right ...the logger is not working and so the application is not working ....what can any one say ? i am muted ... what say folks ?

Wednesday, August 04, 2004

So i am back after hibernation, I was too busy doing nothing ... trying out my hand at developing utilities like FTP in java , SMTP , writing use cases ..writing schedulers to read and generate some stupid reports ..coping with the everyday travel of 3 hours right through main arteries of the city .. just noticed that my ejb skills are becoming a rusty ...an ejb(ean) a day keeps rustiness away !.

Wednesday, June 23, 2004

To except(ion) or not to accept
The usage of checked exceptions in Java has been one of the debatable concepts recently and IMHO it makes sense . seeing the misuse of the exception handling , i can understand the issue about it.

For those who came in late, the big debate is the misuse of the checked exceptions in that the programmers can circumvent the exceptions by either swallowing it or still worse throw an RuntimeException or a subclass of it.
Both the approaches violate the principle of checked exceptions that the user needs to know that there is a risk of something going wrong in the program and hence declare it "throws". The errors (RuntimeException ) on the other hand signify that these are not to be handled and are a result of abnormal conditions and for errors it is not required that the user declare "throws" clause

Also the checked exceptions should be caught and re-thrown at different levels to avoid the coupling of the tiers . Assuming that the EJBTier throws an exception indicating that one of the subsystem failure, this exception has to be caught in the Web tier and an different exception needs to thrown wrapping in it the other exception .The J2SE 1.4 provides an way to wrap the reason in it by providing an constructor which takes in a Throwable object and also an method initcause which takes Throwable as an argument. Using either of the above , one can wrap an exception and throw it doing so will require minimal changes only to the web tier in case the ejb tier changes and no changes to the classes which call the web tier.

On the flip side the code for exception handling becomes more bulkier in that u have a nested of catch blocks trying to catch the exception.

One more way to do this might be to have some constants within the checked exception describing about the errorcodes majorCode and minorCode, major code indicating the severity of the exception as business error or system error ,the minor code would indicate the nature of the exception say "Login failure " or "Dup primary key exists" this approach is for u if u dont mind writing catch block and doing a li'l bit of parsing ... By using this approach the users of this program mainly have to just check the code and act accordingly and a single exception could suffice

see Bruce Eckel's suggestions here

Tuesday, June 08, 2004

Some Java trivia
Here are some of the questions posed to me
Unfortunately i"m not including answers for them

Happy solving ....

1. Static method overriding concepts
2. Pass-by-value concepts read my blog
3. Collections Usage of HashMap ,ArrayList
4.static methods and variables
5.Thread concepts
6.Internationalization and Locales
7. J2EE container Diff components
8.equals() and ==
9. Case scenario coding
10. JMS RemoteQueue PUB/SUB message properties, PTP,
11. JDBC diff types of drivers
12 Diff between AWT and Swing
13. What are the various stages in JVM while loading of the classes
14. Exception handling How do you write your own custom exception class
15.diff kinds of operations provided by HTTP protocol
16. a get request is sent to the servlet which has only doPOSt() defined what will happen
17. How do we load the same connection object twice
18. Difference between POST and Get
19.MessageDrivenBeans concepts and case scenario
20.HOw does MDB differ from session Bean
21.RMI HttpTunneling concepts, stub and skeleton
22. Clustering concepts
23.Diff between String and StringBuffer
24.Diff between ArrayList and Vector
25 Concepts of requestDispatcher.fwd and response.sendRedirect
26.Design Patterns COmmand, Singleton, Mediator, Factory
27.Session replication and Session caching
28. SAX DOM parser JAXP and JAXB
29. Thread program
30. How do we send multiple responses to the client indicating the server is processing the request
THe request is a single request and the user needs to know how the progress o
31.What are the properties of the MessageBody in JMS
32. Diff types of Paradigms in Messaging
33.App server security concepts
34.In what location do u put the classes in a web application
35.In 2 interfaces you declare a variable with the same name what happens when in a class if u extend these
2 interfaces
36. What would happen if u have the same method declaration in both of these interfaces
37.What is Aggregation, Composition, Association and Inheritance
38. What is meant by synchronization



Monday, May 24, 2004

Driving Sense
The traffic scenario in bangalore is divided among 4 players
1. The Monsters Brutual Urban Service a.k.a Bus
2. Weird autorickshaws with crazy messages on top
3. The Misguided Two wheelers and lastly the
4.Cars, trucks and others spewing up smoke

BUS
The don of all the other players, likes to drive in full throttle (brakes are either non existent or not used ) Legend has it that these drivers were once novice cyclists.They still have this characters in them that they turn these buses within a radius of 4.5 mts ...
Main characters include honking incessantly at signals even though a red light is glowing Will stop at non existent bus stops sometimes in the middle of the roads . The private ones are very awful ,keeps u wondering how a bus can accomodate so many ppl and yet move.They think that roads are their own private property.These guys rule the road and
my advice dont go near it ..

Autos
These mavericks have a foul language and are close cousins of the bus drivers,they take u for a ride literally Every artery is choke- a- block with these three wheelers,Their motto in life care a damn to other motorists... drive like barbarians on a rampage...and rely on
uncanny knack of squeezing through any gap.If two autos coming from opposite directions meet they wave hands and stop in the middle of the roads shake hands and discuss about life's problems and as about you well ....make your own road that's what they say. Higly unpredictable and can turn any way they like If u are following them most
likely u will since no one will allow you to overtake them my advice would try and predict which way they will go ...really a tough one .. watch out for these guys


Trucks Cars and others
Late entrants to the traffic scenario but no less crazier than the others..These guys comprise of call center pick and drop vehicles... are known to beat the sound barrier and no lane is small enough for them Try driving in the night you can see these predators prowling in their Qualis , Sumo and other SUV's.etc , travelling at break neck speeds nothing seems to stop them not even humps , craters (pot holes) these guys would give serious competition to the Moto cross champions


Two wheelers : a.k.a misguided missiles known to check the speed limit and other motorist's endurance ... main potent weapon is the horn which they use it more than accelerator or brake... General characterstics include swerving , trial of speed, not caring
a damn about the yellow lines, cant wait till the red signal turns to green...all the other symptoms of road rage can be found in this species.....




Tuesday, May 18, 2004

busy doing nothing .. That's how i would describe the last few days Spending the time in company with Lord of the Rings...the life styles of hobbits ... and the adventures with the ring . The good thing about this book is the style in which the story is narrated, and the characters fit into the story as if they are tailor made be it the ring bearer Frodo or his best friend Sam or the great wizard Gandalf,the gollum,even the dwarf Gimli endears you. The old story truimph of good over evil has been conceptualised well giving clear insights into the life of hobbits , wizards, the kings and even the evil Orcs ,just when you are about to feel that the book is getting a little too predictable , a twist in the tale awaits you around the corner . The best part of the book(so far) is the description of the battle , the seige of Gondor ..
Overall Middle earth has been made picture perfect ...more about it later .. back to ground zero

Monday, April 26, 2004

(Myth v/s Fact) Value or Reference

Java uses Pass-by-value (duh!!) what's so great about it ??,The fact is this innocous looking statement has been twisted, contorted to versions like " Java uses pass-by-value for primitive values and uses pass- by- reference for Objects."
The above statement is false since Java NEVER uses Pass -by -reference only pass -by -value. And when u pass an object to a method its the object reference that is passed by value and not the object itself.

What this means is that the following code will not work as expected
class DBConn {
// wrapper to connection object
}

class Appln{

// create and use DBConn to openConnection
DBConn dbObj = new DBConn(...);
// close the dbconn and make it avail for garbage collection
closeDBConn(dbObj);
// THE db OBJ is still visible here

public closeDBConn(dbObj)
{
dbObj=null;
}
}

THe above snippet of code uses closeDB(dbObj) where the dbobj is initialized to null this would
have worked if Java employs Pass-BY- reference but here it will not . for the simple reason that a duplicate/alias copy of the dbobj reference variable is made and this variable exists within the method scope .so initializing this reference to null will not make the object null

Monday, April 12, 2004

The weekend saw me visiting Coorg, resort called Orange County nestled in a sleepy town called Siddapur,Far from the maddening crowd this place is really amazing, spent the time lazing around watching the river flow,pedal boating on the river Cauvery, and not having to worry about some mundane stuff like changes to JSP which is what I am doing lately ,
So after the rejuvenating experience i am back to reality

Monday, March 29, 2004

De-mystefying coupling

Some of the noteworthy observed during Coupling.
Coupling issues generally come to the fore front while designing using tier architecture.

The following are the lessons learnt

1.When trying to decouple it is always better to attempt decoupling on a Higher level .This would identify and seperate the functionality beforehand.

2. As MartinFowler points out the key is to find out dependancy and once this is achieved try and insulate the modules by using the mapper,This mapper implemented as (preferably) an interface , would be defined in an another package thus providing diff behaviour.

3. We can say objects are tightly coupled when we see import javax.servlet.* in the Action classes where we are implement business logic.

4.Using DTO as means of carriers of data will reduce coupling


5.Avoid cyclic dependancies (identify them early in the lifecycle)


Thursday, March 25, 2004

Used and Abused
Perhaps in the most frequently abused words list i find 'process' to be the leader.The underlying meaning of the word seems to be forgotten long ago, instead more often it serves as a safe haven for people who seem to be awed with the technology and do not wish to consider the change.
Process in the first place must serve to accomplish a given task more quickly ,more efficiently not generate tens of documents consuming more time than the task to be accomplished . Added to this formatting the documents is a pain more than anything else
I like programming for the sheer joy of doing it and so generating documents for the sake of process is not my cup of tea.
Well keep watching this space for more ....

Tuesday, February 24, 2004

Curious to know why the name of the blog is cluster one , This name was inspired by one of the Floyd's song...

I was going through an article which did mention about the qualities a true professional should have ,wherein there was a special emphasis about doing what we enjoy the most rather than doing jobs for other reasons. How true !! I believe there's a lot more about work than waiting for the paycheck at the end of the month.

I"m going through a refresher course on Python, not much progress on that either .. will have to spend some more time to cross from a novice level to a decent programmer

Monday, February 23, 2004

Watch this for further updates