You need to learn how to use Jackson, there is no other way around it, like you were told, you need a default constructor, or an annotated constructor to instruct Jackson how to instantiate your class, like the following example:

public class TestClass  {

  @JsonCreator
  public TestClass(
     @JsonProperty("property1") Type1 property1,
     @JsonProperty("property2") Type2 property2,
     @JsonProperty("property3") Type3 property3,
     @JsonProperty("property4") Type4 property4) {
    ...
    ...
  }
}


And here is an article about it, written by the Jackson author: http://www.cowtowncoder.com/blog/archives/2011/07/entry_457.html

P.D.: Did you take a look at the Exception when your code failed, Jackson exceptions can't be more clear...

Guido.

On 12/11/14 01:43, Ebbinge wrote:
Hello, I am trying to use the MapReduce function that comes along with the
Java API. I am using this code:

try{
             IRiakClient client = RiakFactory.pbcClient("192.168.0.41",
8087);
             Bucket myBucket = client.fetchBucket("Productos").execute();
//Bucket called Productos
             BucketMapReduce m = client.mapReduce("Productos");
             m.addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true);
             MapReduceResult result = m.execute();
             //System.out.println(result.getResultRaw());
             Collection<Producto> tmp = result.getResult(Producto.class);
             for (Producto p : tmp) {
                 System.out.println(p.Nombre+"\n");
             }

             client.shutdown();
} catch(Exception Ex){
             System.out.println(Ex.getMessage());
         }

I have a Producto Class like this:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.StringTokenizer;
import javax.swing.JFileChooser;

/**
  *
  * @author edwinfernandez
  */
public class Producto {
     public String ID;
     public String Nombre;
     public String Descripcion;
     public String Vendedor;
     public String Url;
     public String Precio;
public Producto(String id,String name,String desc,String seller,String
precio,String url){
         ID = id;
         Nombre = name;
         Descripcion = desc;
         Vendedor = seller;
         Precio = precio;
         Url = url;
     }
     public Producto(){
}
}

I can't seem to make it work, I just need to mapreduce the description of
each product in order to get the top ten most used words to describe
products.

Thank you in advance.



--
View this message in context: 
http://riak-users.197444.n3.nabble.com/Riak-API-for-Java-tp4032055.html
Sent from the Riak Users mailing list archive at Nabble.com.

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to