On Mon, Apr 19, 2010 at 12:04, Ahmed Elshereay wrote: > Then I installed jackrabbit-jca on jboss, and I don't know how to configure > spring to obtain the session(hope if you can help me in this it will be > perfect because I'd like to use spring to look after all that stuff although > I know it's not the point to talk about here), Well, can't help you here. I personally don't like the spring-jcr-module stuff, as it is no longer maintained (quite a few people had various complaints that don't get fixed - just search this mailing list for it) and the indirect, hidden way to acquire sessions can be confusing. With the jcr api I would refrain from putting another abstraction layer above it. > so I created my own class > that has getSession() and registerListeners() methods. > > I also created ObservationUtil.java class to registerListener() and check > isRegisteredListener(). > > Session session = repository.login(credentials); > this.registerListeners(session); > return session; registerListeners () and thus the isRegisteredListener() check is always called with a new session. Event listeners are per-session and are running until you log out of that session. Since you alway create a new session when calling getSession(), you end up with many open sessions, each with both of your event listeners registered. Typically you have a session per request (in a webapp context) that you log in upon start of the request, using the actual user if possible (having users and acls in the repository), do your work and logout that session at the end of the request. Event listeners are typically using a "background" session, that is long-running and independent of requests. Hope that helps, Alex -- Alexander Klimetschek alexander.klimetschek@day.com