Problem whith session in EventListener

Hi,

I have a class called MissionEventHandler, that is called by an event of the delete button in the listing in page.

Here is a part of my code:

public void handleEvent(Event event) throws ClientException {alt text

EventContext ctx = event.getContext();
    if (!(ctx instanceof DocumentEventContext)) {
        return;
    }
    DocumentModel doc = ((DocumentEventContext) ctx).getSourceDocument();
    if (doc == null) {
        return;
    }
    String type = doc.getType();

    if ("Mission".equalsIgnoreCase(type) 
                    && event.getName().equalsIgnoreCase("documentRemoved")){
        processMediaRemove(doc, ctx.getCoreSession());
    }

}

private void processMediaRemove(DocumentModel doc, CoreSession session) 
        throws ClientException {


    DocumentModel docTest = session.getDocument(doc.getRef());      <<<----------

    Serializable sml = docTest.getPropertyValue("mission:medias");
}

When I try to retrieve the document from session it returns me the following Exception

2014-04-09 10:34:17,917 ERROR [http-bio-0.0.0.0-8080-exec-44] [org.nuxeo.ecm.core.event.impl.EventServiceImpl] Error during updateMissionRelatedAssets sync listener execution, transaction won't be rolled back since event.markRollBack() was not called by the Listener org.nuxeo.ecm.core.api.ClientException: Failed to get document 8d6c5833-830c-4b9b-9ec6-eb8667dead15

at org.nuxeo.ecm.core.api.AbstractSession.getDocument(AbstractSession.java:1234)
at org.br.ezute.mission.event.MissionEventHandler.processMediaRemove(MissionEventHandler.java:54)
at org.br.ezute.mission.event.MissionEventHandler.handleEvent(MissionEventHandler.java:45)
at org.nuxeo.ecm.core.event.impl.EventServiceImpl.fireEvent(EventServiceImpl.java:215)
at org.nuxeo.ecm.core.api.AbstractSession.fireEvent(AbstractSession.java:385)
at org.nuxeo.ecm.core.api.AbstractSession.notifyEvent(AbstractSession.java:437)
at org.nuxeo.ecm.core.api.AbstractSession.removeNotifyOneDoc(AbstractSession.java:1839)
at org.nuxeo.ecm.core.api.AbstractSession.removeDocument(AbstractSession.java:1786)
at org.nuxeo.ecm.core.api.AbstractSession.removeDocument(AbstractSession.java:1772)

How do I recover my document and at what time the session is updated with CurrentDocument?

Can someone help me?

0 votes

0 answers

3224 views

ANSWER

Hello,

Just a little question, why do you fetch the document that you already have? Also this kind of uuid 8d6c5833-830c-4b9b-9ec6-eb8667dead15 is a little suspicious (dead)… but I guess its normal. In all cases this is indeed weird.

04/10/2014

Hello Vladimir,

Thank You for answer.

It is the same error when I try to access my Schema (mission:medias), without retrieving the document

private void processMediaRemove(DocumentModel doc, CoreSession session)

        throws ClientException {


Serializable sml = doc.getPropertyValue(&quot;mission:medias&quot;);

}

[org.apache.jasper.compiler.TldLocationsCache] At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 2014-04-10 14:16:34,472 ERROR [http-bio-0.0.0.0-8080-exec-13] [org.nuxeo.ecm.core.event.impl.EventServiceImpl] Error during updateMissionRelatedAssets sync listener execution, transaction won't be rolled back since event.markRollBack() was not called by the Listener org.nuxeo.ecm.core.api.ClientException: Failed to get data model for b65cc09c-96eb-454e-9868-2c5d6ab041cf:SchemaImpl(mission)

at org.nuxeo.ecm.core.api.AbstractSession.getDataModel(AbstractSession.java:2632)
at org.nuxeo.ecm.core.api.impl.DocumentModelImpl$2.run(DocumentModelImpl.java:516)
at org.nuxeo.ecm.core.api.impl.DocumentModelImpl$2.run(DocumentModelImpl.java:513)
04/10/2014