I have a tomee server and from android i can call GET methods and works well. Now i try to POST with volley library an entity which has a field java.util.Date but in server i get:
WARNING - Interceptor for {http://services.scol.csd.gr/}MeasureinfoFacadeREST has thrown exception, unwinding now
org.apache.johnzon.mapper.MapperException: java.text.ParseException: Unparseable date: "Sep 23, 2016 13:14:29"
WARNING - Exception in handleFault on interceptor org.apache.cxf.jaxrs.interceptor.JAXRSDefaultFaultOutInterceptor@60d6a046
org.apache.cxf.interceptor.Fault: java.text.ParseException: Unparseable date: "Sep 23, 2016 13:46:36"
Caused by: java.text.ParseException: Unparseable date: "Sep 23, 2016 13:14:29"
at java.text.DateFormat.parse(DateFormat.java:366)
at org.apache.johnzon.mapper.converter.DateConverter.fromString(DateConverter.java:49)
... 48 more
I tried to override johnzon converter like:
in resources.xml:
<?xml version="1.0"?>
<resources>
<Service id="johnzon" class-name="org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider">
accessModeName = field
</Service>
</resources>
in openejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar>
<pojo-deployment class-name="test">
<properties>
cxf.jaxrs.skip-provider-scanning = true
cxf.jaxrs.providers = johnzon,org.apache.openejb.server.cxf.rs.EJBAccessExceptionMapper
</properties>
</pojo-deployment>
</openejb-jar>
in pojo-deployment i give a random name like 'test'
public class LocalDateConverter implements Converter<Date> {
@Override
public String toString(final Date instance) {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTime(instance);
return DatatypeConverter.printDateTime(cal);
}
@Override
public Date fromString(final String text) {
return DatatypeConverter.parseDateTime(text).getTime();
}
}
and then in my entity:
@JohnzonConverter(LocalDateConverter.class)
public Date getDay() {
return day;
}
@JohnzonConverter(LocalDateConverter.class)
public void setDay(Date day) {
this.day = day;
}
I found this configuration from here
but the problem remains.
Any suggestions?
accessModeName = field
so
@JohnzonConverter(LocalDateConverter.class)
goes on the field ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With