Possible bug in SimpleTypeBindings with java.sql.Date
garethevans Jun 30, 2006 6:51 AMHi,
I have an issue using JBoss4.0.4GA and JBossWS1.0.1GA.
My pojo:
public class Client {
private String username;
private java.util.Date dateCreated;
// getters and setters
}
When I create an instance of this class and try to send this via soap all works as expected but when this class is loaded via hibernate I get a classcastexception
javax.xml.rpc.JAXRPCException: Cannot create or send response message at org.jboss.ws.server.ServiceEndpoint.postProcessResponse(ServiceEndpoint.java:296) at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:221) at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:355) at org.jboss.ws.server.StandardEndpointServlet.doPost(StandardEndpointServlet.java:109) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.jboss.ws.server.StandardEndpointServlet.service(StandardEndpointServlet.java:75) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter .... Caused by: java.lang.ClassCastException: java.sql.Date at org.jboss.xb.binding.SimpleTypeBindings.marshal(SimpleTypeBindings.java:1150) at org.jboss.xb.binding.XercesXsMarshaller.marshalCharacters(XercesXsMarshaller.java:1169) at org.jboss.xb.binding.XercesXsMarshaller.marshalSimpleType(XercesXsMarshaller.java:451) at org.jboss.xb.binding.XercesXsMarshaller.marshalElementType(XercesXsMarshaller.java:405) at org.jboss.xb.binding.XercesXsMarshaller.marshalElement(XercesXsMarshaller.java:380) at org.jboss.xb.binding.XercesXsMarshaller.marshalElementOccurence ....
From looking at the code within fisheye you can see that only the type of java.util.Date is checked for:
from SimpleTypeBindings
else if(typeCode == XS_DATETIME)
1140 {
1141 Calendar c;
1142 if(value.getClass() == java.util.Date.class)
1143 {
1144 c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
1145 c.clear();
1146 c.setTime((java.util.Date)value);
1147 }
1148 else
1149 {
1150 c = (Calendar)value;
1151 }
1152 result = marshalDateTime(c);
1153 }
surely the line 1142 should either be changed to:
if(value instanceof java.util.Date)
or
if((value.getClass() == java.util.Date.class) || (value.getClass() == java.sql.Date.class))
Gareth