I am getting below error when trying to initializing a model class and set the velue.
2021-10-29T22:31:59,017 ERROR SecureExceptionHandlerImpl,http-nio-8080-exec-8:116 - No serializer found for class java.util.Timer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
Below is the model class
public class ModelClass implements Serializable {
/**
*
*/
private static final long serialVersionUID = 613977314761191083L;
private String id;
private String name;
private Timer timer;
public ModelClass() {
timer = new Timer();
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.println(name + " " + new Date().toString());
}
}, 0, 2000);
}
/**
* @return the timer
*/
public Timer getTimer() {
return timer;
}
/**
* @param timer the timer to set
*/
public void setTimer(Timer timer) {
this.timer = timer;
}
}
I gone through many suggestion from stackoverflow but could not get any proper solution for it. Could anyone please help me how can I fixed this exception?