Re: [Echo-list] Trying to access ServerContext keeps throwing NPE
Brought to you by:
tliebeck
From: Terry L. <tj...@la...> - 2004-05-16 22:30:15
|
Can you send the exact stack trace? Also, when in your component's life-cycle are you making the call to getEchoInstance()? As I recall the EchoInstance is null until after the super-init() method is called. If you are trying to do your work in the component constructor, you would be having this problem. If this is the case, try overriding init() (and calling super.init() from the overriden method) and do your work there. Also, I have heard that the 1.1 betas use a thread local pattern for obtaining the EchoInstance. This would solve a lot of these problems where the EchoInstance is not accessible in the current state. I know it is probably not feasible to upgrade, but it is something to keep in mind. Good luck. Terry On Sat, 2004-05-15 at 16:25, Thomas Hentschel Lund wrote: > I've tried posting this on the forums, but no reply. So trying here. > Sorry for the double posting, but I cant get further in my development > without this solved. > > I'm running Echo 1.0.3 on JBoss 3.2.3/Tomcat and the echo app is > protected correctly with login to the backend container. > > I am now trying to access the server context in the echo application to > print the username of the person logged in, but whenever I try to access > the server context it keeps throwing me an NPE. > > ServerContext serverCtx = > (ServerContext)(getEchoInstance().getAttribute(ServerContext.ATTRIBUTE_NAME)); > System.err.println("Logged in name:" + > serverCtx.getUserPrincipal().getName()); > > Can anyone give me any hints on what might be wrong? > > Is the server context available "all the time"? Do I need to put the > code somewhere special? > > I've tried looking through the maillist archives, forums and API docs, > but I am just simply stuck. > > Please help - thanks! > > /Thomas > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click > _______________________________________________ > Echo-list mailing list > Ech...@li... > https://lists.sourceforge.net/lists/listinfo/echo-list |