Hi, _userDao shouldn't be null if you annotate it in your applicationContext.xml and grep it out of the ApplicationContext, e.g.
applicationContext.getBean("sessionDestroyedService"); otherwise spring would have already failed as it was not able to autowire _userDao. Best Regards, Ilja Pavkovic Am Donnerstag, 18. Februar 2010 12:52:46 schrieb Andreas Lüdtke: > Ilja, > > thanks for your reply. If I create a service class like the one below, my > _userDao object is always null. This _userDao works perfectly in other > parts of my app. Do I need to inject the dao in a special way? I think the > integration into spring is the problem, because I don't know where to > place the corresponding part in the config/xml files. As I said, my > knowledge of spring is limited. > > My class looks like this: > > @Service > @Transactional > public class SessionDestroyedService > { > @ Autowired > private UserDao _userDao; > > public void forceLogout(String sessionId) > { > if (_userDao == null) > System.out.println("SessionDestroyedService.forceLogout(): _userDao > is NULL"); > else > { > System.out.println("SessionDestroyedService.forceLogout(): _userDao > is OK"); > User user = _userDao.getBySessionId(sessionId); > if (user != null) > { > // do the work here... > } > } > } > } > > Andreas > > > -----Original Message----- > > From: Ilja Pavkovic [mailto:ilja.pavko...@binaere-bauten.de] > > Sent: Wednesday, February 17, 2010 5:38 PM > > To: users@wicket.apache.org > > Subject: Re: best way to detect session termination > > > > Hi, > > > > create a service class marked with Annotation @Transactional > > and manage it > > with spring. Calls to this function will have get a session > > from the spring > > context. > > > > Spring will open a session before calling any function on > > this service and > > close the session afterwards. > > > > @Service > > @Transactional > > public class MyService { > > > > @Autowired > > private MyDao dao; > > > > public destroySession(String sessionId) { > > > > myDao.deleteMySessionById(sessionId); > > > > } > > > > } > > > > Best Regards, > > > > Ilja Pavkovic > > > > Am Mittwoch, 17. Februar 2010 13:24:11 schrieb Andreas Lüdtke: > > > Vineet, > > > > > > I'm now storing the session id in the user record. But now > > > > I have another > > > > > problem, because hibernate tells me now in sessionDestroy(): > > > > > > org.hibernate.HibernateException: No Hibernate Session > > > > bound to thread, and > > > > > configuration does not allow creation of non-transactional one here > > > > > > I'm using spring to inject my dao. I also tried to use the dao in my > > > HttpSessionListener which is configured in web.xml, but > > > > that prevents my > > > > > app from being started by Tomcat. > > > Next I did was to create a manual created hibernate > > > > session, but that > > > > > raised other problems like a missing hibernate.hbm.xml file > > > > and I don't > > > > > want to configure that manually... > > > > > > Does somebody see another way to access my user data, or am I doing > > > something stupid? > > > > > > Andreas > > > > > > > -----Original Message----- > > > > From: vineet semwal [mailto:vineetsemwal1...@gmail.com] > > > > Sent: Tuesday, February 16, 2010 2:15 PM > > > > To: users@wicket.apache.org; sam.lued...@t-online.de > > > > Subject: Re: best way to detect session termination > > > > > > > > can't you simply do that in > > > > webapplication.sessiondestroy(String sessionid), > > > > > > > > you can store the sessionid when user logs in and on > > > > sessiondestroyed > > > > > > ,search the user by this sessionid , > > > > and change whatever in user object and then persist it.. > > > > > > > > On Tue, Feb 16, 2010 at 6:23 PM, Andreas Lüdtke > > > > > > > > <sam.lued...@t-online.de>wrote: > > > > > I studied the classes HttpSessionBindingListener and > > > > > AbstractHttpSessionStore > > > > > as you noted, but I think I'll still have no link between > > > > > > > > the SessionId > > > > > > > > > from > > > > > the HTTPSession and my own Session. Maybe I'm missing > > > > > > > > something or "I don't > > > > > > > > > see the wood among all the trees" as we say in Germany... > > > > > > > > > > Andreas > > > > > > > > > > > -----Original Message----- > > > > > > From: Eelco Hillenius [mailto:eelco.hillen...@gmail.com] > > > > > > Sent: Monday, February 15, 2010 7:08 PM > > > > > > To: sam.lued...@t-online.de > > > > > > Cc: users@wicket.apache.org > > > > > > Subject: Re: best way to detect session termination > > > > > > > > > > > > You could use a HttpSessionBindingListener like Wicket > > > > > > > > does internally > > > > > > > > > > (see AbstractHttpSessionStore). Or as a hack store > > > > > > > > references to the > > > > > > > > > > session objects in the session listener. That's the > > > > easy fix, but > > > > > > > > doesn't scale if you need session replication (unless > > > > > > > > maybe you use > > > > > > > > > > e.g. Terracotta). > > > > > > > > > > > > Eelco > > > > > > > > > > > > On Sun, Feb 14, 2010 at 4:36 AM, Andreas Lüdtke > > > > > > > > > > > > <sam.lued...@t-online.de> wrote: > > > > > > > Hi Eelco, > > > > > > > > > > > > > > thanks for the hint. Now I can detect the end of a session. > > > > > > > > > > > > Unfortunately I > > > > > > > > > > > > > can't access my own wicket session in that > > > > > > > > > > > > sessionDestroyed() method in order > > > > > > > > > > > > > to get the info about the connected user. I've got ther > > > > > > > > > > > > error message > > > > > > > > > > > > > "java.lang.IllegalStateException: you can only locate or > > > > > > > > > > > > create sessions in > > > > > > > > > > > > > the context of a request cycle". > > > > > > > > > > > > > > Do you know how I can achieve this? > > > > > > > > > > > > > > Andreas > > > > > > > > > > > > > >> -----Original Message----- > > > > > > >> From: Eelco Hillenius [mailto:eelco.hillen...@gmail.com] > > > > > > >> Sent: Saturday, February 13, 2010 7:02 PM > > > > > > >> To: users@wicket.apache.org; sam.lued...@t-online.de > > > > > > >> Subject: Re: best way to detect session termination > > > > http://www.xyzws.com/Servletfaq/when-do-i-use-httpsessionlistener/7 > > > > > > > > >> Eelco > > > > > > >> > > > > > > >> On Sat, Feb 13, 2010 at 8:38 AM, Andreas Lüdtke > > > > > > >> > > > > > > >> <sam.lued...@t-online.de> wrote: > > > > > > >> > I would like to detect the termination of the > > > > > > > > session to set the > > > > > > > > > > >> > "lastAccesTime" in the user profile. This should also > > > > > > >> > > > > > > >> happen if the session > > > > > > >> > > > > > > >> > times out. > > > > > > >> > > > > > > > >> > I read in archive about a HttpSessionListener that should > > > > > > >> > > > > > > >> do the trick. > > > > > > >> > > > > > > >> > Unfortunately I can't find a place to install it. > > > > > > >> > > > > > > > >> > Thanks > > > > > > >> > > > > > > > >> > Andreas > > > > --------------------------------------------------------------------- > > > > > > > > >> > To unsubscribe, e-mail: > > users-unsubscr...@wicket.apache.org > > > > > > > > >> > For additional commands, e-mail: > > users-h...@wicket.apache.org > > > > > > --------------------------------------------------------------------- > > > > > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > --------------------------------------------------------------------- > > > > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org -- binaere bauten gmbh · tempelhofer ufer 1a · 10961 berlin +49 · 171 · 9342 465 Handelsregister: HRB 115854 - Amtsgericht Charlottenburg Geschäftsführer: Dipl.-Inform. Ilja Pavkovic, Dipl.-Inform. Jost Becker --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org