Faisal,
I see
at least two possible problems with your below code:
1) You
are not checking the correct log files so you are missing the logged messages
explaining where your code is going wrong. You keep resetting your
"sites" item to a
"new LinkedList()" before returning it. In your code example you reset
"sites" in two distinct places to a blank LinkedList which could explain your
out of bounds index message:
Caused by: java.lang.StringIndexOutOfBoundsException : String
index out of range: -1
2) You
are passing your exceptions up the code tree when an exception is throw other
than the ONE Exception you look for in your catch statement:
BaseViewException. Try changing that to a simple and generic "Exception"
class so you catch and log ALL TYPES of exceptions without risking them
being thrown up the chain and bypassing the rest of the code in your
method.
Additionally, I have some constructive criticism
for you:
Resending posts is considered rude, especially 3 times as you seem to
have. If you are unsure about a post getting through you should check a
list archive site such as nabble.com. If no one answers your
post
it
often has one of 3 reasons:
1. The person or persons helping you do not yet
have time to review your post.
2.
Your problem is completely unrelated to other people's work that no one is
interested in your issue.
3.
Your question could be so obvious no one wants to spend time answering it.
(rarest)
Also, if you had taken the last 3 days to learn how to
use a debugger (I use Eclipse 3.2 for with
a Tomcat plugIn allowing for live webapp debugging) I'm sure you would have
solved your problem a long time ago and been on to your next coding
issue. Plus, the 2 suggestions I made are very common problem
solving techniques. Since there are plenty of other in-code debugging
techniques around, I recommend you skim the net (search engine) to find new ways
to debug java webapps. And in case
you were wondering, I am self-taught so I didn't learn any of these techniques
in a class but through various books and some of the programming lists I
subscribe to, like this one.
That being said, be sure to let us know if these two
main suggestions helped.
Regards,
David
-----Original Message-----Below is my managed bean. In the constructor, I get a reference to the managed property from Spring just to verify that it is available. I placed breakpoints in the code at the getSiteList() method, and my breakpoint is never hit prior to the error occuring.
From: Faisal Mahmoud [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 10, 2006 4:03 PM
To: MyFaces Discussion
Subject: Issue with referencing a ManagedBean
public List getSiteList()
{
// David Friedman] Cut Code not important to this reply.
List sites = null;
try
{
sites = this.ftpSiteDelegate.getFtpSitesBySawUser(sawUser);
}
catch (BaseViewException e)
{
logger.error(e);
/./ Did the above error log? Here you reset your sites to a blank, which would cause error -1 index etc.
//TODO: FacesMessage here
sites = new LinkedList();
}
if (sites == null)
{
// TODO: FacesMessage here
NullPointerException e = new NullPointerException("Retrieved a NULL reference to a List of FtpSite objects.");
logger.error(e);
// Did the above error log? Here you reset your sites to a blank, which would cause the error -1 index etc
sites = new LinkedList();
}
logger.debug("Returning a List of FtpSites objects for SawUser, userId = " + sawUser.getUserId());
return sites;
}

