reset password
Author Message
hmodi
Posts: 27
Posted 15:48 Oct 29, 2010 |

Hi Professor/class members,

Its silly error for me. But I have following problem. I am retrieving username using

User user = userDao.getUserByName( SecurityUtils.getUsername() );

  After that I am able to print information about user e.g., name, cin etc on console.

But when I pass this object (user) to function e.g., fileDao.getTopLevelFolders( user );

I am getting NullPointerException errot. I also tried static way

User user = userDao.getUserByName( "s0001" );

But its still same error.

I have attached csns log.

Looking for reply.

Attachments:
cysun
Posts: 2935
Posted 15:50 Oct 29, 2010 |

You need to do this kind of debugging yourself.

hmodi
Posts: 27
Posted 16:01 Oct 29, 2010 |

Thanks Professor,

I tried but at present I ran out of all options and any guidelines will appreciated.

cysun
Posts: 2935
Posted 16:04 Oct 29, 2010 |

Try harder.

hmodi
Posts: 27
Posted 16:32 Oct 29, 2010 |

Sorry, professor, but I have spent enough time since today morning(6.00AM).

I  looked at similar examples from csns and I followed similarly.

HW3 examples works with similar way. So what else could be the problem?

getTopLevelFolders requires User object and which I am retreiving from the userDao.getUserByName( SecurityUtils.getUsername()), which returns User object so its not any casting problem!

So pleaseeeeeee give some hint.

cysun
Posts: 2935
Posted 16:36 Oct 29, 2010 |

Spending hours debugging a simple problem is something every programmer has to go through.

With that said I'll do you a favor this time. Check the line where the error happens carefully. Is the NullPointerException caused by user being null or is it caused by something else (e.g. userDao being null)?

hmodi
Posts: 27
Posted 16:51 Oct 29, 2010 |

Thank you, I will have hint now.