How to deploy Nuxeo Automation Client in Java Example

Hello, I am trying to execute the example on Nuxeo Automation Client in Java given on the link http://doc.nuxeo.com/display/NXDOC/Using+Nuxeo+Automation+Client. As described in the instructions, I'm using the resources that follow:

  • nuxeo-automation-client-5.6-I20120428_0115-sources.jar

  • json-lib-2.4.jar

  • ezmorph-1.0.6.jar

  • httpcore-4.2-alpha2.jar

  • httpclient-4.1.2.jar

  • mail-1.4.5.jar

    all of them downloaded from https://maven.nuxeo.org/. I've also resolved the dependencies in pom.xml. Currently I'm having the following dependency error:

/ Exception in thread “main” java.lang.NoClassDefFoundError: org/codehaus/jackson/map/type/TypeModifier at org.nuxeo.ecm.automation.client.jaxrs.spi.Request.handleResult(Request.java:117) /

I've looked for the jar containg this class, but I can't find it in the resources listed above. I just don't want to use external jars. What am I missing?

Thank u in advance, Ervin

0 votes

1 answers

3117 views

ANSWER



Hello,

Since Nuxeo 5.6 (the nuxeo-automation-client you chose is a 5.6 date-based version, aka a milestone waiting for 5.6 release), json-lib is being replaced with jackson.

When you want some information about the third-party libraries' versions used/recommended in Nuxeo, you should look at our corporate POM org.nuxeo:nuxeo-ecm. Here is dependency information about json-lib and jackson:

<!-- deprecated - use jackson instead -->
<dependency>
  <groupId>net.sf.json-lib</groupId>
  <artifactId>json-lib</artifactId>
  <version>2.4</version>
  <classifier>jdk15</classifier>
</dependency>
<dependency>
  <groupId>org.codehaus.jackson</groupId>
  <artifactId>jackson-core-asl</artifactId>
  <version>1.8.1</version>
</dependency>
<dependency>
  <groupId>org.codehaus.jackson</groupId>
  <artifactId>jackson-mapper-asl</artifactId>
  <version>1.8.1</version>
</dependency>

When you encounter a java.lang.ClassNotFoundException (or java.lang.NoClassDefFoundError), first look into our Maven repository for the artifacts providing the wanted class, then find in our corporate POM which artifact matches the previous list.

Note if your project is built with Maven, you can automatically retrieve the dependencyManagement from the Nuxeo corporate POM version corresponding to the automation client you use (or any POM inheriting from org.nuxeo:nuxeo-ecm such as org.nuxeo:nuxeo-addons-parent or org.nuxeo.ecm.distribution:nuxeo-distribution). For instance, in your case, you would set the following in your project POM:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.nuxeo.ecm.distribution</groupId>
      <artifactId>nuxeo-distribution</artifactId>
      <version>5.6-I20120428_0115</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
<dependencies>
  <dependency>
    <groupId>org.nuxeo.ecm.automation</groupId>
    <artifactId>nuxeo-automation-client</artifactId>
  </dependency>
  <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-core-asl</artifactId>
  </dependency>
  <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
  </dependency>
  <dependency>
    <groupId>net.sf.ezmorph</groupId>
    <artifactId>ezmorph</artifactId>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
  </dependency>
  <dependency>
    <groupId>javax.mail</groupId>
    <artifactId>mail</artifactId>
  </dependency>
</dependencies>

That way, you don't have to worry about versions and you can easily upgrade Nuxeo.

0 votes