Thursday, April 17, 2008

Solution: java.lang.NoClassDefFoundError: org/apache/ode/tools/sendsoap/cline/HttpSoapSender

Of late, I have been involved in evaluating a few workflow engines to see their usefulness for my purpose. One of the candidates was Apache Ode. Just that it was a product of Apache itself qualified it for the evaluation.

I was trying to get it up on a linux box, specifically Ubuntu 7.10. I had it deployed in tomcat and Apache Ode was up and running. I tried testing it with

bin/sendsoap http://localhost:8080/ode/processes/helloWorld examples/HelloWorld2/testRequest.soap


It came back with java.lang.NoClassDefFoundError: org/apache/ode/tools/sendsoap/cline/HttpSoapSender

Examining the sendmail code , this stood out.
# Add Ode libraries
for f in ls $LIB/*.jar
do
LOCALCLASSPATH=$LOCALCLASSPATH:$f
done

While this is intended to get all jar files in $LIB path, it fails when there is a space in $LIB path.

The path I was working out of was /home/sharmi/Work/trials/apache ode/apache-ode-war-1.1.1
The space in 'apache ode' was the spoiler.
Changing the path to /home/sharmi/Work/trials/apacheode/apache-ode-war-1.1.1 did the trick :)

Friday, February 29, 2008

Budget India 2008 - Mixed Reactions

The Union Budget for 2008-2009 was announced today by the Finance Mininster Dr. Chindambaram. It is certainly a relief for tax payers as quoted by the Hindu

The Finance Minister has raised the income tax exemption limit from Rs. 1,10,000 to Rs. 1,50,000, thus giving every assessee a relief at minimum of Rs. 4,000. The tax rate will be 10 per cent for the income slab between Rs. 1,50,001 and Rs. 3,00,000 and 20 per cent between Rs. 3,00,001 and Rs. 5,00,000. For income of Rs. 5,00,001 and above the income tax rate will be 30 per cent. The exemption limit for women assessees has been increased to Rs. 1,80,000 and in case of senior citizens to Rs. 2,25,000. The Finance Minister has not proposed any change in corporate income tax and in the rate of surcharge. A person paying medical insurance premium for his parents will be allowed an additional deduction of Rs. 15,000 under Section 80D.
While this is certainly a relief, what the action of bringing
asset management service provided under ULIP, services provided by stock/commodity exchanges and clearing houses, right to use goods in cases where VAT is not payable, and customized software under Services Tax is to be seen. This would be significant because, people tend to invest mostly in mutual funds and stocks to avail tax exemption through investment.

The
Rs. 60,000 crore debt relief package for farmers is a cause of concern only spreads worry and dissent. Don't get me wrong. I do understand that farmers need help direly. What I do see is that every government tends to give debt waivers at every instant possible. This actually creates a mindset that farmers need not pay nationalized banks debts as they will be waivered anyway. What is required is that farmers are able to better utilize their resources, availability of better tools for their job, proper irrigation is available, land fertility is maintained and they have all the basic necessities and facilities like schools, clean drinking water, health care. We are yet to see these reach the farmers. What progress and awareness we see among them are rarely government's efforts but are works of some dedicated individuals, NGOs or the urban progress slowly percolating to their level. But real progress is yet to reach the grass-root levels. All the development works planned by the government are sucked dry before they reach the target audience. Only when the corruption in the system is uprooted and accountability and self-discipline sets in, will we truly see 'India Shining'.

Monday, January 14, 2008

Pitfalls in handling multiple exceptions: UnboundLocalError: local: 'ValueError'

The below code raised UnboundedLocalException for 'ValueError' which is builtin. I wondered how it could be unbounded and tried to figure out what went wrong and this is what I got.
              try:
#code to do something
if (condition):
raise ValueError
except java.lang.NullPointerException, ValueError:
#code to print exception message
continue



UnboundLocalError: local: 'ValueError'


This is when I learnt about one of the inner workings of python.

The python interpretor scans the code block once. if a name is bound to a variable with out being specified as global, it is considered local.
e.g:

x = 2
def func():
x = 3
print x
func()
print x


will print

3

2

This is because in func, x is bound locally to the variable containing the value <3>.

But the same function with the small difference will fail with 'UnBoundLocalError: local: x':
x = 2
def func():
print x
x = 3
func()
print x


This is again because, the interpreter first scans func. It sees x is bound locally as it is assigned a value 3 within the innerscope. When it tries to execute, the print statement precedes the binding statement. At the point, x is a free variable with no binding. Hence the error.

Now in the case of the exception handling,

The construct is


try:
#Do something
except Exception, e:
#e is bound to exception obj.
#Do something with e


e is actually bound to the instance of the class Exception and becomes a local variable.

Now considering the initial scenario, the ValueError name is bound to the instance of the 'java.lang.NullPointerException' exception. This overrides the scope of the global builtins and makes ValueError a binding to local variable and the binding happens at the except line. So when raise ValueError is called an UnboundLocalError is thrown.

So how to we handle multiple exceptions?

              try:
#code to do something
if (condition):
raise ValueError
except (java.lang.NullPointerException, ValueError):
#code to print exception message
continue



For more interesting patterns see here.

Wednesday, January 2, 2008

Why I love Python

When I met an old friend of mine, he inquired about my work. I replied, rather gushed out, that it was wonderful 'cause I was working in a dynamic language called python. He gave me a quizzical look and asked how could you call work is good because the language is good, for after all language was just the tool. I listed out some of the features of python but somehow I felt it was not sufficient reason. Then we drifted on to to other topics.

Later, I thought back on the issue. Why I fell in love with Python is almost the story of my life. I got introduced to computers in my third grade. That was a time when computers were still rare in schools almost non-existent in homes. Then we just tried executing basic programs already created by our teachers or play games. One such program would get your name as input and print "Hello `name`" as output. I was fascinated! The next two years we spent learning who Charles Babbage was and what ENIAC was. In 5th and 6th grade I finally got to write BASIC programs. We wrote programs to calculate squares, students marks and generate multiplication tables. Normal though it seems now, I was thrilled! With a few lines of instructions, I could make the computer calculate almost anything! I took special pride in the fact that I could express my solution much better than most of my class mates. I had decided I'm going to work with computers in the future.

Then I had to change schools. My new school did not have computer classes until 11th.
When I finally got to go near computers, we started at BASIC and went on to Visual Basic. Things progressed and I got an opportunity do my B.Tech in Information Technology in a prestigious Institution. In our first sem, we had a C course which ended a disaster due to various tragicomic reasons. In our second sem, we got a wonderful Prof Mr. V. Ramachandran, who in a very short span of time, taught us C, C++ and Java, carefully ensuring we understood the underlying design, its implications and relative differences. We liked programming in C. But C++ seemed to be design filled with complications for the sake of complication. Java was relatively better. Most of our projects were done in C++ or Java. So either we spent a lot of time debugging or doing a tour of referencing to write a line of code. Some where in the process, the focus of programming shifted from understanding and solving the problem to getting constructs right and searching for the right class and method. And with that went most of the joy in programming. I still relished classes that dealt with logic like Data structures, networks, distributed OSes but I started drifting away slowly from programming.


Then I joined this cool startup that promised to bring everything under the sun to your handheld. And they used python. That was were I saw Python for the first time and It was love at first sight. The zen of Python captured my heart and all the joy of programming came back to me. Now I did not have to worry unnecessarily abt pointers or obscure constructs and factories. (Don't get me wrong, I do respect C and C++'s ability to get below the hood, but they are just an overkill for most apps ) I could spend my efforts on finding an efficient solution and as and when I reorganize my solution, my code could be reorganized with minimal effort. The coded solutions were mostly optimal but in some cases were optimization was desired, a simple change in construct would suffice. In only one situation, we had to do a C implementation for the bottleneck module.

I have been working for two years now. Python has helped me improve my coding discipline and productivity a lot. I am able to appreciate the value of Linux and vim better. It has also made me more receptive towards new languages.

Thank you, Python!

Friday, March 16, 2007

Cheese, cheese and more cheese

Take a plate layered with cheese .. Now add some cheese on top of it .. Sprinkle some pasta .. Cover it all with cheese .. Now garnish your wonderful dish with cheese .. yeah ,, and you have the freedom to add your own names and qualifiers before the word 'cheese' above .. Italians really know how to live their life .. If you are a gourmet, probably that is where you got to be .. To do them justice, their soups, starters, and desserts where excellent though the poor Indian in me could never take the cheese lavished on me ..

To put it in context , one of my friends was leaving our office and taking off to more fun filled pastures and we got together in this sweet little Italian restaurant to bid him 'adieu'. Food or not, I had a great time with my friends .. A nice break from the hectic schedules and never ending queries

Friday, February 2, 2007

The Good Ol' Days

I keep hearing about the good Old days when everything was so perfect and shiny..

People !! Wake UP!!

The good Old days are over..

so many people dream about the good old days, keep peering back with extra thick glasses , but fail to notice that the present is quietly slipping away, right before their unseeing eyes.

If you are really honest with yourself, you'll agree that the past was not all that perfect. So is our present.. It is not perfect. Yeah there are a few things that you would wish you can bury 10 feet deep but it is not going to happen. Atleast not as easily as you think. What we really got to do is encourage the goodness of the present. Identify the bad and denounce it. What may seem good to you may not be so to me. But when the collective thought of the society is applied, it will lead to evolution... evolution of ideas and behaviours. We'll leave a better society to the next generation, and a better generation to look after the society.

Lonely , In the Past

On TV, David Attenborough was doing what he did best, giving an exciting yet calm narration of human evolution. As he described the changes the Mayan civilization underwent, something he said set my head buzzing.. "Mayan civilization's Capital City housed 60 thousand residents" ... Capital City? Just 60 thousand? Thats a flourishing civilization? Well, there was more to come .. He remarked "the total human population in the world was 15 million" .. Wait!! Thats less that the total population of New York (18 M) !! The first feeling that stuck me was ,, Lonliness.. The worlds would have been very different.. You get out of your domain.. It may be ages and ages and you might never meet a single human being! Whooh.. The second feeling was more profound .. If that was the stable population for a long time, then how did this sudden explosion happen? Are we not becoming more of a parasite on this world? Is it not time to give what we took? Sure the winner takes it all .. But after the world is gone, will we still be winners? Hmmm.. questions .. Our actions and the future holds the answers ..