Hi,

On Mon, 2016-05-02 at 13:16 -0700, Andreas Schaefer Sr. wrote:
> Hi
> 
> I am trying to listen for node creation events and use WebDav
> connection:
> 
> session.getWorkspace().getObservationManager().addEventListener()
> 
> Unfortunately I cannot make this work neither in AEM 6.1 nor in Sling
> 8.

Looking at the SlingDavExServlet code I don't see any XML manipulation,
so this should be reported to the Jackrabbit project.

Thanks,

Robert

> 
> What I see is that I get a DavException: (200) OK which is cause by
> XML parsing error.
> 
> Looking at the content that is returned from the SlingDavExServlet is
> containing “<jcr:primaryType/>” which is not defined in the XML
> header as namespace and therefore the parsing fails (see
> DavMethodBase.getResponseBodyAsDocument()).
> 
> This is the content I receive from the server:
> 
> [                Change Polling] content                        DEBUG
> << "<dcr:eventdiscovery xmlns:dcr="http://www.day.com/jcr/webdav/1.0
> <http://www.day.com/jcr/webdav/1.0>"><dcr:eventbundle><dcr:event><D:h
> ref
> xmlns:D="DAV:">http://localhost:4502/crx/server/crx.default/jcr%3aroo
> t/var/discovery/impl/clusterInstances/2c6fc55d-ef6c-42be-b9ec-
> e90febf7e6de/lastHeartbeat</D:href><dcr:eventtype><dcr:propertychange
> d/></dcr:eventtype><dcr:eventuserid>admin</dcr:eventuserid>
> <http://localhost:4502/crx/server/crx.default/jcr%3aroot/var/discover
> y/impl/clusterInstances/2c6fc55d-ef6c-42be-b9ec-
> e90febf7e6de/lastHeartbeat%3C/D:href%3E%3Cdcr:eventtype%3E%3Cdcr:prop
> ertychanged/%3E%3C/dcr:eventtype%3E%3Cdcr:eventuserid%3Eadmin%3C/dcr:
> eventuserid%3E><dcr:eventuserdata/><dcr:eventdate>1462220040858</dcr:
> eventdate><dcr:eventidentifier>/var/discovery/impl/clusterInstances/2
> c6fc55d-ef6c-42be-b9ec-
> e90febf7e6de</dcr:eventidentifier><dcr:eventinfo><jcr:primaryType>sli
> ng:Folder</jcr:primaryType><beforeValue>2016-05-02T13:13:30.856-
> 07:00</beforeValue><afterValue>2016-05-02T13:14:00.858-
> 07:00</afterValue></dcr:eventinfo></dcr:event></dcr:eventbundle></dcr
> :eventdiscovery>”
> 
> This is an exception I see:
> 
> java.io.IOException: XML parsing error
>       at
> org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getResponse
> BodyAsDocument(DavMethodBase.java:130)
>       at
> org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getRootElem
> ent(DavMethodBase.java:150)
>       at
> org.apache.jackrabbit.webdav.client.methods.PollMethod.processRespons
> eBody(PollMethod.java:101)
>       at
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodB
> ase.java:1749)
>       at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.j
> ava:1098)
>       at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Htt
> pMethodDirector.java:398)
>       at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMe
> thodDirector.java:171)
>       at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav
> a:397)
>       at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav
> a:323)
>       at
> org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.poll(RepositorySe
> rviceImpl.java:2378)
>       at
> org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.getEvents(Reposit
> oryServiceImpl.java:2179)
>       at
> org.apache.jackrabbit.jcr2spi.WorkspaceManager$ChangePolling.run(Work
> spaceManager.java:1240)
>       at java.lang.Thread.run(Thread.java:745)
> Caused by: org.xml.sax.SAXParseException; lineNumber: 1;
> columnNumber: 628; The prefix "jcr" for element "jcr:primaryType" is
> not bound.
>       at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAX
> ParseException(ErrorHandlerWrapper.java:203)
>       at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalErro
> r(ErrorHandlerWrapper.java:177)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
> XMLErrorReporter.java:441)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
> XMLErrorReporter.java:368)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
> XMLErrorReporter.java:325)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
> StartElement(XMLNSDocumentScannerImpl.java:289)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> l$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786
> )
>       at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(X
> MLDocumentScannerImpl.java:606)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next
> (XMLNSDocumentScannerImpl.java:117)
>       at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> l.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
>       at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
> ML11Configuration.java:848)
>       at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
> ML11Configuration.java:777)
>       at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
> java:141)
>       at
> com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.
> java:243)
>       at
> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Doc
> umentBuilderImpl.java:348)
>       at
> javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
>       at
> org.apache.jackrabbit.webdav.xml.DomUtil.parseDocument(DomUtil.java:1
> 27)
>       at
> org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getResponse
> BodyAsDocument(DavMethodBase.java:121)
>       ... 12 more
> 
> 
> I use Jackrabbit 2.10.0 to connect to the server.
> 
> This is my test code:
> 
> import org.apache.jackrabbit.commons.JcrUtils;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> 
> import javax.jcr.LoginException;
> import javax.jcr.NoSuchWorkspaceException;
> import javax.jcr.Node;
> import javax.jcr.Repository;
> import javax.jcr.RepositoryException;
> import javax.jcr.Session;
> import javax.jcr.SimpleCredentials;
> import javax.jcr.observation.EventIterator;
> import javax.jcr.observation.EventListener;
> 
> public class TestCamelMain {
> 
>     private final Logger LOG =
> LoggerFactory.getLogger(TestCamelMain.class);
> 
> //    public static final String URL = "http://localhost:8080/server";
> ;
>     public static final String URL = "http://localhost:4502/crx/serve
> r";
> //    public static final String URL = "http://localhost:4502/crx/rep
> ository";
>     public static final String user = "admin";
>     public static final String path = "/etc/framemaker/inbox";
>     private static final String WORKSPACE = "crx.default";
> //    private static final String WORKSPACE = "default";
> 
>     private TestCamelMain main;
>  
>     public static void main(String[] args) throws Exception {
>         TestCamelMain example = new TestCamelMain();
>         example.boot();
>     }
>  
>     public void boot() throws Exception {
>         Session session = null;
>         try
>         {
>             LOG.info("Getting repository.");
>             final Repository repository =
> JcrUtils.getRepository(URL);
> 
>             LOG.info("Getting Session.");
>             session = repository.login(
>                 new SimpleCredentials(user, user.toCharArray()),
>                 WORKSPACE);
> 
>             LOG.info("Getting parent node.");
>             Node parent = session.getNode(path);
>             if (null == parent)
>             {
>                 LOG.error("Node not found at {}", path);
>                 return;
>             }
> 
>               String[] uuid = null;
> //            String uuids = getJcrEndpoint().getUuids();
> //
> //            if (uuids != null) {
> //                uuids = uuids.trim();
> //
> //                if (!"".equals(uuids)) {
> //                    uuid = uuids.split(",");
> //                }
> //            }
> 
>               String[] nodeTypeName = null;
> //            String nodeTypeNames =
> getJcrEndpoint().getNodeTypeNames();
> //
> //            if (nodeTypeNames != null) {
> //                nodeTypeNames = nodeTypeNames.trim();
> //
> //                if (!"".equals(nodeTypeNames)) {
> //                    nodeTypeName = nodeTypeNames.split(",");
> //                }
> //            }
> 
>             session.getWorkspace().getObservationManager().addEventLi
> stener(
>                 new MyEventListener(),
>                 3,
>                 path,
>                 true,
>                 uuid,
>                 nodeTypeName,
>                 false
>             );
> 
>             Thread.sleep(3600 * 1000);
>         } catch (LoginException e)
>         {
>             LOG.error("Cannot login.", e);
>         } catch (NoSuchWorkspaceException e)
>         {
>             LOG.error("No such workspace.", e);
>         } catch (RepositoryException e)
>         {
>             LOG.error("Cannot connect to repository.", e);
>         } finally {
>             if (null != session) {
>                 session.logout();
>                 LOG.info("Closing session.");
>             }
>         }
>     }
> 
>     public class MyEventListener
>         implements EventListener
>     {
> 
>         @Override
>         public void onEvent(EventIterator events) {
>             if(events != null) {
>                 while(events.hasNext()) {
>                     LOG.info("Got Event: " + events.next());
>                 }
>             } else {
>                 LOG.info("Events Iterator is null");
>             }
>         }
>     }
> 
> }



Reply via email to