"Cannot Find Bean in any Scope" Problem
Hello There..
Good Morning to everyone reading my post.
I have a problem, I have No clue how to solve. in the past I have been able to fix the "Cannot find bean in any Scope" problem, but now I have no idea Why I am getting that message.
Here's the scenario:
I have an Action that forwards to a JSP page. that Action has an implementation class that puts some String Values in Session like this:
request.getSession().setAttribute("name", name);
request.getSession().setAttribute("lastName", lastName);
and then redirects to the JSP page
When the JSP page loads the first time, there is no problem. But this JSP page has anAction of its own, that redirects to itself
This Action is triggered by a Submit Button, calls another Action implementation class and then redirects to itself.
But when this Action that redirects to itself executes, the variables that I put in session in the previous Action get Lost. And I get an "Cannot Find Bean under namename in any Scope
Could anybody help me to know what I am doing wrong?
I am trully Clueless !
[1196 byte] By [
BCE_Josea] at [2007-11-26 22:56:49]

# 1
if ur using the response.sendRedirect() then u lost the data that u stored in request scope.oki think that is the problem.use requestDispatcher.forward(req,res);it will works
# 2
Actually I am using Struts.
therefore I use an Struts Action. and do something like this:
return mapping.findforward("itself");
And the mapping in the struts-config.xml file tells the Struts engine to forward the page to itself.
But I don't see Why my Data gets lost.
Thank you very much for the reply
# 3
Well, when you lose data during a redirection process it's (as far as I know) in most cases a flush-problem. Are you sure the data doesn't get flushed while it's redirecting? If so: find the flush-boolean (or create it manually) and make it 'false'.
That did the trick when I had the same kind of problem - though I didn't work with Struts.
# 4
Oh Hi there!
Thanks for the reply.
It is really strange I'd say what is Happening because in my redirection I am Updating a Collection (adding one value to it) and then putting it in Session and forwarding the JSP to itself. and that particular Session variable--the Collection never gets Lost.
So you see the only values in Session that get Lost are the ones that come From the Previous Action Class.
and finally sir, I don't know how to deal with the Flushing you're telling me about.
Could you put some sample code?
Thank you very much.
# 5
are you using any Struts taglibs? I've seen this happen when mixing HTML and taglibs incorrectly, for instance, using struts html tags inside a standard HTML form (the inner tags look for beans inside their enclosing struts tags, which of course don't exist)
# 6
See if you are setting into the session a null value into the attribute "name" or "surname" on some other page........
thus when you come back to your previous page the attribute is null and it throws the exception.
first check for null in the jsp using the <logic:present name = "name"> tag.
If the part of the code does not get executed which lies between the <logic:present> tags then conclude that the session attribute "name" is set to null at some other page.
I hope this solves your problem...........
all the best...
# 7
Sesions are cookie based and cookies are only returned to the server that loaded them. If you access your web app using a url like
http;//localhost:8080/MyWebApp
but you redirect uses the url
http://127.0.0.1:8080/MyWebApp
The browser sees this as two different servers and will not send the session cookie in the redirect. This will mean that the data stored in the session is not available.
Make sure that the redirect url uses the same url address as the original request.
# 8
Good Morning here!
Thank you all for the fabulous responses!
First of all, let me mention an important Fact. I am using The Struts Layout Library to build dependent Combo Boxes. so My enclosing html tag is <html:layout>
I am not sure If this has an influence on how Struts verifies the existence of Session Beans/Variables.
As I mentioned before: Action Class1 puts some variables in session and forwards to the JSP page in Question, those values load well the first time, and get printed in the JSP.
The JSP page has an Action Class2, triggered by a submit button, Action Class2 forwards to the same JSP page, But when this Action Class2 is called the values that were put in Session using Action Class1 get Lost.
tolmank, your reply is Very Interesting, because my server is internally changing my IP address to somename:8080. Are you sure this is what definitely could be causing the problem?
Thanks to all of you guys!
God Bless.
Post your comments... and let me know what you think.
# 9
> if ur using the response.sendRedirect() then u
> lost the data that u stored in request scope.oki
> think that is the problem.
>
> use requestDispatcher.forward(req,res);
> it will works
Wrong again.
@OP is pulling session values. Weather he uses a forward() or redirect() is irrelevant.
>tolmank, your reply is Very Interesting, because my
>server is internally changing my IP address to
>somename:8080. Are you sure this is what definitely
>could be causing the problem?
It's definitely worth investigating. The problem you're having is certainly indicitive of a cookie that is unable to be read. A mismatched host name is always the first suspect..
Message was edited by:
bckrispi
# 10
Hello fellas !
Hi there bckrispi,
it seems indeed that my server is internally changing my IP address, it translates it from ###.###.###.### to somename. and it takes the somename from a mapping inside a HOSTS file.
When the JSP page first loads, and I right click the page and go to properties, the IP address appears, bur When I hit the Submit Button, and return to the page, and go check the properties this time, the IP is changed to the name inside the corresponding mapping of the HOSTS file.
Any suggestion on how could I avoid this server name change from happening?
Thank you very Much !
You guys do a fantastic job everyday !
God Bless!