In my EJB I use a JCR session to store a File. I then logout of the session and throw a CDI event. The EJB which observes the CDI event then creates a new JCR session in which it wants to use the stored file. (Note: I had to add a delay in order to get this to work because for some reason the file wasn't available directly after storing it). After the method is done with using the file I also logout of this session. However after 15 minutes I get the exception "Attempt to close session-a84d60ac-1c8f-4cad-bc5a-84102b12f8e5-385 after it has already been closed." with stacktrace :
Stack trace of the duplicate attempt to close session-c7bc3b30-9a5f-4922-bf80-8f197c583370-389
at org.apache.jackrabbit.core.session.SessionState.close(SessionState.java:280) ~[jackrabbit-core-2.4.2.jar:na]
at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:943) [jackrabbit-core-2.4.2.jar:na]
at org.apache.jackrabbit.core.XASessionImpl.logout(XASessionImpl.java:392) [jackrabbit-core-2.4.2.jar:na]
at org.apache.jackrabbit.jca.JCAManagedConnection.cleanup(JCAManagedConnection.java:169) [jackrabbit-jca-2.4.2.jar:na]
at ...
and after 1 hour :
Unclosed session detected. The session was opened here: java.lang.Exception: Stack Trace
at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:222) ~[jackrabbit-core-2.4.2.jar:na]
at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:239) ~[jackrabbit-core-2.4.2.jar:na]
at org.apache.jackrabbit.core.XASessionImpl.<init>(XASessionImpl.java:99) ~[jackrabbit-core-2.4.2.jar:na]
at ...
I believe this is because the application server (Glassfish v.3.1.2.2) tries to close the session I already closed. But when I don't close any sessions, I also get an exception where it says that the pool size limit is reached. How can I avoid my problem?