Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-667

Remote test of getting adapter for document leads to NPE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Runtime

      Description

      Sample remote test in placefulservice:

      public void testDBAnnotation() throws Exception {
      DocumentModel root = _getRootDocument();
      DocumentModel file = new DocumentModelImpl(root.getPathAsString(),
      "file", "File");

      file = _createChildDocument(file);

      DBAnnotatableDocument adoc = file.getAdapter(DBAnnotatableDocument.class);
      SubscriptionConfig config = new SubscriptionConfig();
      config.setId("xxx");
      config.setEvent("publish");
      adoc.setAnnotation("SubscriptionConfig", "val1");
      }

      leads to:
      java.lang.NullPointerException
      at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.findAdapter(DocumentModelImpl.java:454)
      at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.getAdapter(DocumentModelImpl.java:429)
      ...

      which happens in:
      private <T> T findAdapter(Class<T> itf) {
      DocumentAdapterService svc = (DocumentAdapterService) NXRuntime
      .getRuntime().getComponent(DocumentAdapterService.NAME);

      of DocumentModelImpl.java in org.nuxeo.ecm.core.api.impl

      server.log:
      2007-02-27 14:51:19,443 INFO [org.nuxeo.ecm.core.api.adapter.DocumentAdapterService] Registered document adapter factorynull: interface org.nuxeo.ecm.platform.ec.placeful.DBAnnotatableDocument

      The same NPE happens in standard remote tests in TestAPI.java in
      // TODO: fix and reenable.
      public void testDocumentAdapter() throws Exception

      { DocumentModel root = _getRootDocument(); DocumentModel file = new DocumentModelImpl(root.getPathAsString(), "file", "File"); file = _createChildDocument(file); AnnotatedDocument adoc = file.getAdapter(AnnotatedDocument.class); assertNotNull(adoc); adoc.putAnnotation("key1", "val1"); adoc.putAnnotation("key2", "val2"); assertEquals("val1", adoc.getAnnotation("key1")); assertEquals("val2", adoc.getAnnotation("key2")); adoc = file.getAdapter(AnnotatedDocument.class); assertEquals("val1", adoc.getAnnotation("key1")); assertEquals("val2", adoc.getAnnotation("key2")); }

      which is btw disabled at the moment.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: