Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2417

Event listener throwing RepositoryException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • 4.2.0.Final
    • 3.8.1.Final
    • None
    • None
    • Hide
      package org.modeshape.jcr;
      
      import javax.jcr.Session;
      import javax.jcr.observation.Event;
      import javax.jcr.observation.EventIterator;
      import javax.jcr.observation.EventListener;
      
      import org.junit.Test;
      import org.modeshape.test.ModeShapeMultiUseTest;
      
      public class EventListenerTest extends ModeShapeMultiUseTest {
      
        @Test
        public void testEventListening() throws Exception {
          Session session = getSession();
      
          final int eventTypes = Event.NODE_ADDED + Event.NODE_REMOVED + Event.PROPERTY_CHANGED;
      
          final String[] nodeTypeNames = new String[] {"nt:unstructured"};
          session.getWorkspace().getObservationManager()
              .addEventListener(new SimpleEventListener(), eventTypes, "/", true, null, nodeTypeNames, false);
      
      
          Session newSession = getSession();
          
          newSession.getRootNode().addNode("unstructuredNode", "nt:unstructured");
          newSession.save();
        }
      
        private class SimpleEventListener implements EventListener {
      
          @Override
          public void onEvent(EventIterator events) {
            // TODO Auto-generated method stub
      
          }
      
        }
      
      
      }
      
      
      Show
      package org.modeshape.jcr; import javax.jcr.Session; import javax.jcr.observation.Event; import javax.jcr.observation.EventIterator; import javax.jcr.observation.EventListener; import org.junit.Test; import org.modeshape.test.ModeShapeMultiUseTest; public class EventListenerTest extends ModeShapeMultiUseTest { @Test public void testEventListening() throws Exception { Session session = getSession(); final int eventTypes = Event.NODE_ADDED + Event.NODE_REMOVED + Event.PROPERTY_CHANGED; final String [] nodeTypeNames = new String [] { "nt:unstructured" }; session.getWorkspace().getObservationManager() .addEventListener( new SimpleEventListener(), eventTypes, "/" , true , null , nodeTypeNames, false ); Session newSession = getSession(); newSession.getRootNode().addNode( "unstructuredNode" , "nt:unstructured" ); newSession.save(); } private class SimpleEventListener implements EventListener { @Override public void onEvent(EventIterator events) { // TODO Auto-generated method stub } } }

    Description

      When registering an EventListener, I get a "Session has been closed and can no longer be used." exception.

      Feb 02, 2015 5:01:01 PM org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter acceptBasedOnNodeTypeName
      SEVERE: Error checking primary type 'null' with mixins of 'null' against type names of '[nt:unstructured]'
      javax.jcr.RepositoryException: The session with an ID of 'afe12ef9d' has been closed and can no longer be used. 
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wesssel Wessel Nieboer (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: