Exception while communicating with Nuxeo Automation Server

I have nuxeo DM 5.5 up and running at http://localhost:8080/nuxeo/site/automation I am trying to access Nuxeo EP 5.5 Automation server from Nuxeo Java automation client as under:

public static void main(String[] args) throws Exception {
    HttpAutomationClient client = new HttpAutomationClient(
    Session session = client.getSession("Administrator", "Administrator");
    Documents docs = (Documents) session.newRequest("Document.Query").set(
           "query", "SELECT * FROM Document").execute();

But, the above code giving me the following exception:

java.lang.RuntimeException: Cannot execute {Content-Type=application/json+nxrequest, Accept=application/json+nxentity, */*, Authorization=Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y}
at org.nuxeo.ecm.automation.client.jaxrs.impl.HttpConnector.execute(HttpConnector.java:87)
at org.nuxeo.ecm.automation.client.jaxrs.spi.ConnectorHandler.execute(ConnectorHandler.java:28)
at org.nuxeo.ecm.automation.client.jaxrs.spi.DefaultSession.execute(DefaultSession.java:94)
at org.nuxeo.ecm.automation.client.jaxrs.spi.DefaultOperationRequest.execute(DefaultOperationRequest.java:155)
at com.redmath.recm.versionrnd.VersionManipulator.main(VersionManipulator.java:22)
Caused by: java.lang.NullPointerException
at org.nuxeo.ecm.automation.client.jaxrs.spi.marshallers.DocumentMarshaller.readDocument(DocumentMarshaller.java:53)
at org.nuxeo.ecm.automation.client.jaxrs.spi.marshallers.DocumentsMarshaller.readDocumentEntries(DocumentsMarshaller.java:42)
at org.nuxeo.ecm.automation.client.jaxrs.spi.marshallers.DocumentsMarshaller.readDocuments(DocumentsMarshaller.java:53)
at org.nuxeo.ecm.automation.client.jaxrs.spi.marshallers.DocumentsMarshaller.read(DocumentsMarshaller.java:94)
at org.nuxeo.ecm.automation.client.jaxrs.spi.marshallers.DocumentsMarshaller.read(DocumentsMarshaller.java:1)
at org.nuxeo.ecm.automation.client.jaxrs.spi.JsonMarshalling.readEntity(JsonMarshalling.java:143)
at org.nuxeo.ecm.automation.client.jaxrs.spi.Request.handleResult(Request.java:115)
at org.nuxeo.ecm.automation.client.jaxrs.impl.HttpConnector.execute(HttpConnector.java:121)
at org.nuxeo.ecm.automation.client.jaxrs.impl.HttpConnector.execute(HttpConnector.java:83)
... 4 more

I am stuck :( please help me out.

0 votes

1 answers



Can you give us the exact version of the nuxeo-automation-client jar. The line given in the stack do not correspond to the 5.5 source code.

I just took the same example (modified slightly) and ran without issue against an existing 5.5 repository using Administrator credentials. If you paste the Automation server URL into a browser command line, enter credentials, can you then download and open the resulting JSON? Is there any chance it's a rights issue? Do you have all the required libraries on the build path? Here are the versions I used: httpclient-4.1.1, httpcore-4.1, nuxeo-automation-client-5.5-SNAPSHOT, ezmorph-1.0.4, json-lib-2.2.1-jdk15, mail-1.4.jar, jackson-mapper-asl-1.81, and jackson-core-asl-1.8.1 (actually the last two aren't mentioned in Nuxeo docs as dependencies but i did need them to get my example to work).

Anywhere here's the code I just created and used…

import org.nuxeo.ecm.automation.client.Session;
import org.nuxeo.ecm.automation.client.jaxrs.impl.HttpAutomationClient;
import org.nuxeo.ecm.automation.client.model.Documents;

public class testautomation {   
  public static void main(String[] args) {

      String url = "";

      HttpAutomationClient client = new HttpAutomationClient(url);

      Session session = client.getSession("Administrator", "Administrator");
      Documents docs = null;

        try {
            docs = (Documents) session.newRequest("Document.Query").set(
                    "query", "SELECT * FROM Document").execute();
        } catch (Exception e) {
            // TODO Auto-generated catch block

        if (docs != null)
            System.out.println("No documents found");

0 votes

Bruce, I am able to download JSON response when I hit the URL on my browser. Actually I am able to run my example successfully with Nuxeo 5.4.2. But with Nuxeo 5.5 it gives me the above exception.

Further, I had different lib versions as compared to yours, so I tried my example with your lib versions and it gave me this on my console:

The java class could not be loaded. java.lang.UnsupportedClassVersionError: (org/nuxeo/ecm/automation/client/jaxrs/impl/HttpAutomationClient) bad major version at offset=6

I think there must be some java version conflict. Bruce can you tell me which Java version are you using?


I'm running 1.6.0_30 - 64 bit