• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NullPointerException @ validation interceptor

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there I got a Null pointer Exception when trying to save an obj...
what actually happen is when I implemented validation interceptor while inserting customer obj into DB, I got the NPE .
if I remove that interceptor, it works fine.

But, I need validation implemented. so, how can i bypass?

thanks.



the following is my action class


and this is my struts.xml file



My dao class is as follow



my validation xml is as follow


 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How is the member variable session set in your DAO? I suspect your @SessionTarget annotation is not working and session is null when the code tries to add a customer.
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
James..

It turns out that it is not because of Session, it is somewhere @ value stack or at struts.xml file.

when I implement the following code in my struts.xml file (without validation interceptor)



and insert customer as named "p". I got the following at concole meaning that it is working perfectly.



and in my debug mode at my jsp page. I got the following information.


Now, what i believe is , due the implementation of "validation" interceptor, my value stack become empty or having null.
why is that so?
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Where is the interceptor called validation defined?
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using predefine interceptor .
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it working...
and I have to change my struts.xml file as follow



This is intend for those who are like me(newbie) in Struts and Hibernate...

You see no 1 and 5 is required as I am using full hibernate plugin. And according to the rule, there should be basic stack or default stack in your newly created stack.
without that you will get nullPointerException.

you see no 2 is required this is because ( you might need to go above of this page and look for "CustomerAction", which is implemented using modeldriven.)
for that reason you need it. again if you do not turn on ModelDriven Interceptor, you will get NullPointerException.

you see no 3 is required this is because somewhere in my application (which you can not have a reference here), username and password is required and that params interceptor is required for that reason.
without that again NPE.

and No 4 is the validation which is required to validate against user input.
that is all ...


(if i state something wrong here, I will happily take any suggestion and improvement.)
Thanks...
reply
    Bookmark Topic Watch Topic
  • New Topic