I have followed a tutorial(struts2,spring and hibernate integration)(set of code snippets) on a website and tried to develop below example according to my needs but I am not able to see appropriated details in view(JSP).
Even after referring to original resource and many other resources I am not able to figure out the issue.
I have copied/attached code snippets and screen-shot of view(JSP) below :
CommentorBoImpl(Service class implementing interface CommentorBo)
CommentorDAOImpl(DAO class implementing CommentorDAO interface)
Commentor.hbm.xml(Hibernate mapping file)
commentor.jsp(Struts view page(same page is being returned on either adding or listing the commentors))
attached below(first screen-shot) is screen-shot when I am trying to access the application first time(without adding a commentor).
second screen-shot is of page which used to appear after you have entered details and hit submit button.It can be seen that action url has been changed(from listCommentor.action to addCommentor.action).
But I am not able to see the list of commentors which are already been added.
I can see that arraylist is not empty from logs and can confirm that details are being inserted in database properly but not able to display over JSP(commentor.jsp)
Could you please give me an idea..
Also please let me know in case I would have to add other config files(struts,spring) to problem posted.
I can see in logs that these methods are not being invoked in my action class(CommentorAction.java)..
Apart from above I can sniff that commentorList.size() is throwing a null pointer exception while execution of commentor.jsp:
2014-06-11 19:59:27,744 [ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)' DEBUG ognl.OgnlValueStack - Caught an exception while evaluating expression 'commentorList.size()>0' against value stack
java.lang.NullPointerException: target is null for method size
As I said in my previous post, your method names should be in Camel Case. I even provided you with what the method name should be.
Struts uses reflection to discover properties at run time. If you don't follow the JavaBeans Specification standards on accessor naming, Struts will not be able to find your properties.
I got it working finally.... ...thanks
But with one glitch ....when I am refreshing the page and even if there is no record in database,automatically last inserted row is displayed..not sure why?
and why I haven't got any error when my setters/getters were not in camel case.
Thanks for your help so far
Ankit Tripathi wrote:
when I am refreshing the page and even if there is no record in database,automatically last inserted row is displayed..not sure why?
How is it displaying the "last inserted row" if "there is no record in database"?
When you "refresh" the page, you are making a request to the server. That executes an action...
Ankit Tripathi wrote:
why I haven't got any error when my setters/getters were not in camel case.
Struts eats a lot of errors that some think would give better feedback to a developer: see this article Make sure you turn on devmode so you get all the feedback that Struts can give (and make sure you turn it off in production!)