Lucas Mireles wrote:You say you are implementing SessionAware but you did not implement setSession.
You should have:
Mark Spritzler wrote:While I am not sure if LocalSessionFactoryBean has a property called eventListeners.
It looks to me like you have a circular reference going on here and Spring can't figure out which comes first, the Chicken or the Egg.
SessionFactory --- EventListeners -- EventListener -- EventListernerDAO -- SessionFactory
See how the references/dependencies work its way back to the SessionFactory.
Mark
Mark Spritzler wrote:Well, I found a few problems.
1) User and Order should not be a Spring Bean, they are domain objects and hold state. Not good for a Spring Bean
2) You are creating an ApplicationContext object directly in your OrderService, it should be outside of your classes that you are defining as Beans. So one problem is everytime you call addOrder, it goes and creates a brand new ApplicationContext. You should only have one of these for your entire application. ApplicationContext is a heavy-weight object that can take a little bit of time to instantiate, There is a whole bunch of steps in Initialization that occurs when creating an ApplicationContext.
3) This is not a Spring bug, but a Hibernate issue. You have from User to Order a cascade option, but you do not have a cascade option from Order to User. And since you save the Order, it will not do anything to User. And I would assume this is a new user and the database would have a FK constraint in Order table for the user id. So the User information must be in the User table before any Order can be inserted into the Order table for that User. But you are looking up a User, so if it exists in the database, then that wouldn't be a problem.
Please post your exception stack trace because we are missing that context information on what is you actual problem.
Mark
Sean Clark wrote:Hey,
I think you just want to save the username in the session, I'm not sure you can use <jsp: setAttribut> to pass the username to servlet(B).
The only other option I can see would be to send the username as part of JSP(B)'s form as a hidden input and read it again in servlet(B), though I personally wouldn't do this as this value could be tampered with by the client.
Your choice though.
Sean
Bear Bibeault wrote:Again, I'm confused. A JSP is the end target of a request. Anything done in the JSP should be for the sole purpose of rendering the display. So saying things like "passing the value of <c:set> to a filter" doesn't make a whole lot of sense. What is it that you are really trying to do?
Bear Bibeault wrote:Your question makes no sense as stated. What is the relationship between the JSP and the servlet? Why are you just using normal request parameters? Why would a servlet need info from the JSP that isn't submitted as part of a form?