Hello everybody. I'm trying to save some data related to an user when login. I am using the UserCounterListener.java:
public void attributeAdded(HttpSessionBindingEvent event) { if (event.getName().equals(EVENT_KEY) && !isAnonymous()) { SecurityContext securityContext = (SecurityContext) event.getValue(); if (securityContext.getAuthentication().getPrincipal() instanceof User) { User user = (User) securityContext.getAuthentication().getPrincipal(); log.debug("Creating default data to the user " + user.getId()); //Inserting the data UserData userData = userDataManager.getClientData(user.getId().longValue()); addUsername(user); } } } The method returns an error: java.lang.NullPointerException at com.proyecto.webapp.listener.UserCounterListener.attributeAdded(UserCounterListener.java:126) at org.mortbay.jetty.servlet.AbstractSessionManager$Session.setAttribute(AbstractSessionManager.java:1077) at org.springframework.security.context.HttpSessionContextIntegrationFilter.storeSecurityContextInSession(HttpSessionContextIntegrationFilter.java:392) ... when i login with the default admin:admin user. Even the program never reach the method getClientData() in the UserDataManager. What i am doing wrong? May be, it's not possible to access to a service from a Listener? thank you. -- View this message in context: http://appfuse.547863.n4.nabble.com/Trying-to-save-some-data-in-database-when-login-tp2022951p2022951.html Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net For additional commands, e-mail: users-h...@appfuse.dev.java.net