Thanks for your reply.
I was doing it in Java. And I actually made a mistake of setting the value to null, instead of not setting it at all. When I commented the below line, it did work. But this is just to make it work without the CostPerUnitDistance and MaxTotalDistance. I still don't know how to setup a distance attribute.Do you know how to setup a distance attribute if I am using the SDC Street dataset provided by ESRI?