aspose file tools*
The moose likes JSF and the fly likes View cannot be restored exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "View cannot be restored exception" Watch "View cannot be restored exception" New topic
Author

View cannot be restored exception

Gvn Karthik
Greenhorn

Joined: Feb 07, 2011
Posts: 22
Hi,

I'm using Eclipse Helios, Apache Tomcat 6.0.29 and JSF 1.2. I'm having a simple application which has a Login page, Home Page and a Logout page. Once the user logs in, a session variable is set and Home page is displayed which has a logout button. When I launch Eclipse and run the Login page and use the correct credentials, I'm able to go to the home page but when I re-run the Login page, I get an error saying "view cannot be restored".

How do I resolve this exception? PFB the exception.



Also, when I re-run the application and when the Login page comes up, I press the refresh button in the Eclipse browser and after that I dont get any such exception. If I dont refresh the login page after a re-run of the application, I get the above exception. How do I get rid of this exception?
naveen gupta
Ranch Hand

Joined: Apr 12, 2006
Posts: 129
i am not sure i understood correctly

so are you trying to say, first time you login it works fine but after you logout and login again it fails?
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

Not sure why you're using a session variable. If you're in JSF then your login page should call a method in your backing bean that runs the authentication, and if successful, returns a success message. Your faces-config.xml should then have a navigation rule that will direct the user to the home page when login is successful.

If you're not sure how that works then I'd recommend getting a good JSF book or find a JSF tutorial online. Navigation rules are a basic part of JSF and would save you a huge amount of effort.
Gvn Karthik
Greenhorn

Joined: Feb 07, 2011
Posts: 22
Once the user logs in, he will be directed to a home page where he has to fill in a form which updates a table in the database in the back end. In that table I'm inserting the username across the user who has successfully logged in. That's why I'm using a session variable. Also, I can have tasks that can be done in a user-specific manner. If the user updates his personal details, then I can use the value of the session variable to query my database and update according to the user who has logged in.


But the exception which is coming up here is creating a problem, I mean it is trying to fetch a view which no longer exists. PFB the code in my backing bean.



Any suggestions to resolve this exception? But, here is the catch. When I run it for the second time after I launch eclipse and then refresh the login page by pressing the reload button on the eclipse browser; I don't get this exception. So, as a workaround I thought I will use javascript to automatically reload the login page as it loads. I know this is not how I should be doing but I think this might help.
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

I understand how you're using the session variable, I just think you'd be better off making it a member of the LoginBean class.

Anyway, what is the scope of your LoginBean as configured in your faces-config.xml?
Gvn Karthik
Greenhorn

Joined: Feb 07, 2011
Posts: 22
I have put the LoginBean class in session scope.
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

Have you only run this thing within Eclipse, or have you tried running it from within Tomcat separately?
Gvn Karthik
Greenhorn

Joined: Feb 07, 2011
Posts: 22
I didn't get your question. I have configured Tomcat as my server in Eclipse to run my application. And I run the application in Eclipse only.
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

I'd suggest deploying it to Tomcat separately, maybe on a separate instance of Tomcat on your machine, then see if you get the same behavior.

The reason is by eliminating Eclipse from the equation we can eliminate the possibility that there's an issue with different versions of .jars, etc.
 
wood burning stoves
 
subject: View cannot be restored exception