Gson asking for Integer TypeAdapter

I am trying to serialize/deserialize a quite big object (that’s why I will not write the whole object here) from and to json using Gson.
I have created TypeAdapter to DateTime and LocalDate but it still goes wrong with exception:

java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: java.lang.Integer. Forgot to register a type adapter?

But as I have read in Gson docs, Integer does not need a TypeAdapter so I have check all the inner-objects inside this looking for something which needs an adapter and I found these non-primitive types:

Sets, List, Array, Enum

I have looked for them all and it seems like no one of these needs a TypeAdapter.

I am using this code to serialize the object:

Gson gson = new GsonBuilder()
            //these adapters are already tested and everything went right
            .registerTypeAdapter(DateTime.class, new DateTimeJsonConverter())
            .registerTypeAdapter(LocalDate.class, new LocalDateJsonConverter())

WStepWork returnValue = new WStepWorkBL().getStep(id, currentUserId);

String json = gson.toJson(returnValue);

Does anyone knows if I actually need a TypeAdapter for any of these four or what is possibly going wrong?

Thanks in advance.

I have looking for the error and it’s caused because of this:

public class WExternalMethod implements {

    //many attributes
    private String[] paramlistName;

    private Class[] paramlistType;  


<class name="org.beeblos.bpm.core.model.WExternalMethod" table="w_process_head_method">
    <property name="paramlistName"
            <column name="paramlist_name">
                <comment>for APP synchro: parameter list to send</comment>
        <property name="paramlistType"
            <column name="paramlist_type">
                <comment>for APP synchro: parameter list types (java types)</comment>

It was a missunderstood. It was asking for a TypeAdapter to Class and not to Integer so I did:

public class ClassJsonConverter implements JsonSerializer<Class>, JsonDeserializer<Class> {

    public ClassJsonConverter(){

    public JsonElement serialize(Class src, Type srcType, JsonSerializationContext context) {
        String str = src.getName();
        return new JsonPrimitive(str);

    public Class deserialize(JsonElement json, Type type, JsonDeserializationContext context)
            throws JsonParseException {

        Class returnValue = null; 
        try {
            String str = json.getAsString();
            returnValue = Class.forName(str);
            return returnValue;
        } catch (IllegalArgumentException e) {
            return null;
        } catch (ClassNotFoundException e) {
            String mess = "deserialize(): " 
                    + (e.getMessage()!=null?". "+e.getMessage():"")
                    + (e.getCause()!=null?". "+e.getCause():"");

        return returnValue;