Actualmente estoy trabajando con VOLLEY , en android studio , tengo el siguiente metodo
String rq = RequestManager.login(numeroTelefonico,pass);
GenericController gC = new GenericController();
gC.login(Login.this, rq, new Response.Listener<LoginMapeador>() {
@Override
public void onResponse(LoginMapeador response) {
LoginMapeador auxx = response ;
progressDialog.dismiss();
Intent intent = new Intent(Login.this, Home.class);
startActivity(intent);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(Login.this, "Error con el servidor,Comuniquese con el soporte ", Toast.LENGTH_LONG).show();
progressDialog.dismiss();
}
});
El cual a al hora de probar el RQ generado por medio de POSTMAN , si recibo una respuesta correcta , y tengo otros servicios utilizando la misma metodologia y estan andando , pero aqui este me tira error en android.context.ContextWrapper , y me dice algo de
Conflicting setter definitions for property "wallpaper"
la clase que me muestra que tengo mal es la de ObjetRequest
public class ObjetRequest<T> extends JsonRequest<T> {
JsonRequest<T> {
@JsonIgnore
private final Class<T> clazz;
@JsonIgnore
private final ObjectMapper mapper = new ObjectMapper();
@JsonIgnore
private String myCookie;
@JsonIgnore
private static final String MSG = "Error en respuesta";
/**
* Creates a new request.
*
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param request A {@link String} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public ObjetRequest(int method, String url, Class<T> clazz, String request, Listener<T> listener, ErrorListener errorListener) {
super(method, url, request, listener, errorListener);
this.clazz = clazz;
}
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
try {
if (this.getMyCookie() == null || this.getMyCookie().equals("")) {
this.setMyCookie(response.headers.get("Set-Cookie"));
}
String json = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
T tmp = mapper.readValue(json, clazz); // ACA MARCA EL LOG
return Response.success(tmp, HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
Log.e("Net", MSG, e);
return Response.error(new ParseError(e));
} catch (JsonParseException e) {
Log.e("Net", MSG, e);
return Response.error(new ParseError(e));
} catch (JsonMappingException e) {
Log.e("Net", MSG, e);
return Response.error(new ParseError(e));
} catch (IOException e) {
Log.e("Net", MSG, e);
return Response.error(new ParseError(e));
}
}
public String getMyCookie() {
return myCookie;
}
public void setMyCookie(String myCookie) {
this.myCookie = myCookie;
} }`
12-18 11:01:40.115 17602-17881/com.myapp.test.bimo E/Net: Error en respuesta com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "wallpaper": android.content.ContextWrapper#setWallpaper(1 params) vs android.content.ContextWrapper#setWallpaper(1 params) at [Source: {"headerRS":{"orgMsgId":"MMJSON","orgChannelRef":"ChannelReference","orgChannelId":"BIMOAPP","orgTransactionType":"LOGIN.LG-M-OL-S","timestamp":"2017-12-18T11:01:39-03:00","errorCode":"0","errorDesc":""},"messageRS":{"errorCode":"-34444","description":"Login no autorizado","sessionToken":"","needChangePassword":"","needRecoveryInfo":"","DATA":""}}; line: 1, column: 1] at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:268) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244) at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:476) at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3899) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3794) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842) at com.myapp.test.volley.ObjetRequest.parseNetworkResponse(ObjetRequest.java:57) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:123) Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property "wallpaper": android.content.ContextWrapper#setWallpaper(1 params) vs android.content.ContextWrapper#setWallpaper(1 params) at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getSetter(POJOPropertyBuilder.java:319) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.filterBeanProps(BeanDeserializerFactory.java:602) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:497) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:226) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:141) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244) at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:476) at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3899) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3794) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842) at com.myapp.test.volley.ObjetRequest.parseNetworkResponse(ObjetRequest.java:57) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:123) 12-18 11:01:40.155 17602-17602/com.myapp.test.bimo D/ViewRootImpl: #3 mView = null
Agrego las clases para mapear la respuesta
public class LoginMapeador {
@JsonIgnore
private HeaderRS headerRS ;
@JsonIgnore
private LoginRS messageRS;
public LoginMapeador(){
this.headerRS = new HeaderRS();
this.messageRS = new LoginRS();
}
public HeaderRS getHeaderRS() {
return headerRS;
}
public void setHeaderRS(HeaderRS headerRS) {
this.headerRS = headerRS;
}
public LoginRS getMessageRS() {
return messageRS;
}
public void setMessageRS(LoginRS messageRS) {
this.messageRS = messageRS;
}
}
Clase HeaderRS
public class HeaderRS {
@JsonIgnore
@JsonProperty("orgMsgId")
private String orgMsgId;
@JsonIgnore
@JsonProperty("orgChannelRef")
private String orgChannelRef;
@JsonIgnore
@JsonProperty("orgChannelId")
private String orgChannelId;
@JsonIgnore
@JsonProperty("orgTransactionType")
private String orgTransactionType;
@JsonIgnore
@JsonProperty("errorCode")
private String errorCode;
@JsonIgnore
@JsonProperty("errorDesc")
private String errorDesc;
@JsonIgnore
@JsonProperty("timestamp")
private String timestamp;
public HeaderRS(){
}
public HeaderRS(String orgMsgId, String orgChannelRef, String orgChannelId, String orgTransactionType, String errorCode, String errorDesc,String timestamp) {
this.orgMsgId = orgMsgId;
this.orgChannelRef = orgChannelRef;
this.orgChannelId = orgChannelId;
this.orgTransactionType = orgTransactionType;
this.errorCode = errorCode;
this.errorDesc = errorDesc;
this.timestamp = timestamp;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getOrgMsgId() {
return orgMsgId;
}
public void setOrgMsgId(String orgMsgId) {
this.orgMsgId = orgMsgId;
}
public String getOrgChannelRef() {
return orgChannelRef;
}
public void setOrgChannelRef(String orgChannelRef) {
this.orgChannelRef = orgChannelRef;
}
public String getOrgChannelId() {
return orgChannelId;
}
public void setOrgChannelId(String orgChannelId) {
this.orgChannelId = orgChannelId;
}
public String getOrgTransactionType() {
return orgTransactionType;
}
public void setOrgTransactionType(String orgTransactionType) {
this.orgTransactionType = orgTransactionType;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorDesc() {
return errorDesc;
}
public void setErrorDesc(String errorDesc) {
this.errorDesc = errorDesc;
}
}
Clase MessageRS
public class LoginRS {
@JsonIgnore
@JsonProperty("errorCode")
private String errorCode;
@JsonIgnore
@JsonProperty("description")
private String description;
@JsonIgnore
@JsonProperty("sessionToken")
private String sessionToken;
@JsonIgnore
@JsonProperty("DATA")
private String DATA;
@JsonIgnore
@JsonProperty("needChangePassword")
private String needChangePassword;
@JsonIgnore
@JsonProperty("needRecoveryInfo")
private String needRecoveryInfo;
public LoginRS (){
}
public LoginRS(String errorCode, String description, String sessionToken, String DATA, String needChangePassword, String needRecoveryInfo) {
this();
this.errorCode = errorCode;
this.description = description;
this.sessionToken = sessionToken;
this.DATA = DATA;
this.needChangePassword = needChangePassword;
this.needRecoveryInfo = needRecoveryInfo;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSessionToken() {
return sessionToken;
}
public void setSessionToken(String sessionToken) {
this.sessionToken = sessionToken;
}
public String getDATA() {
return DATA;
}
public void setDATA(String DATA) {
this.DATA = DATA;
}
public String getNeedChangePassword() {
return needChangePassword;
}
public void setNeedChangePassword(String needChangePassword) {
this.needChangePassword = needChangePassword;
}
public String getNeedRecoveryInfo() {
return needRecoveryInfo;
}
public void setNeedRecoveryInfo(String needRecoveryInfo) {
this.needRecoveryInfo = needRecoveryInfo;
}
}
Busqueda del metodo en todo el proyecto
Para Inicializar el ObjetRequest tengo una clase GenericControleer que en el consutrctor hace
public GenericController() {
objectRequest = new ObjetRequest<>(1, "", BaseRequest.class, "", new Response.Listener<BaseRequest>() {
@Override
public void onResponse(BaseRequest response) {
// response
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Error
}
});
}
, debo tener unos 20 servicios andando con esta misma extructura pero no quiere andar con este , el generic controller , lo doy de alta aqui
GenericController gC = new GenericController();
gC.login(Login.this, rq, new Response.Listener<LoginMapeador>() {
@Override
public void onResponse(LoginMapeador response) {
LoginMapeador auxx = response ;
progressDialog.dismiss();
Intent intent = new Intent(Login.this, Home.class);
startActivity(intent);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(Login.this, "Error con el servidor,Comuniquese con el soporte ", Toast.LENGTH_LONG).show();
progressDialog.dismiss();
}
});
setWallpaper
. ¿Por qué no muestras el código de dicha clase?@JsonIgnore
. Esa anotación es para propiedades que no existan en el JSON de respuesta. O sea, si en el POJO hay alguna propiedad que no esté en el JSON debe tener esa anotación, pero yo veo que tienes todo anotado para ser ignorado, ¿por qué?