Mantis - Resin
Viewing Issue Advanced Details
1532 minor always 01-02-07 09:36 01-02-07 12:50
ferg  
ferg  
normal  
closed  
fixed  
none    
none 3.0.23  
0001532: CMP java.util.Date vs java.sql.Date cast exception
(rep by Andrew Barton)


For reference, I have attached CachedImage.ejb where the ejbSelect
query in question is defined. I have also attached
CachedImageBean.java with my debug code attached.

The schema for the table in question is listed at the bottom of this
message. You will notice I am using a mysql 'datetime' data type for
the modified date.

The problem method is:
public Date ejbHomeGetModifiedDate(Integer key) {
System.out.println("CachedImageBean.ejbHomeGetModifiedDate() -
key: " + key);
try{
System.out.println("CachedImageBean.ejbHomeGetModifiedDate
(): " + ejbSelectModifiedDate(key));
return new Date();
}
catch (FinderException e){
return null;
}
}

public abstract Date ejbSelectModifiedDate(Integer id) throws
FinderException;

When the return type for ejbSelectModifiedDate is defined as a
java.util.Date, I get the following exception:
--
javax.servlet.ServletException: java.lang.ClassCastException
at eblox.commons.image.BaseCachedImageServlet.service
(BaseCachedImageServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter
(ServletFilterChain.java:106)
at com.caucho.server.webapp.WebAppFilterChain.doFilter
(WebAppFilterChain.java:173)
at com.caucho.server.dispatch.ServletInvocation.service
(ServletInvocation.java:229)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:
274)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:511)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:520)
at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
at java.lang.Thread.run(Thread.java:552)
Caused by: java.lang.ClassCastException
at _ejb.CachedImageBean.CachedImageBean__EJB
$Bean.ejbSelectModifiedDate(CachedImageBean__EJB.java:309)
at eblox.commons.image.CachedImageBean.ejbHomeGetModifiedDate
(CachedImageBean.java:15)
at _ejb.CachedImageBean.CachedImageBean__EJB
$LocalHome.getModifiedDate(CachedImageBean__EJB.java:487)
at eblox.commons.image.CachedImageServlet.getModifiedDate
(CachedImageServlet.java:24)
at eblox.commons.image.BaseCachedImageServlet.service
(BaseCachedImageServlet.java:63)
... 9 more
--
This was the previous state. When I define the return type as
java.sql.Date as in:

public abstract java.sql.Date ejbSelectModifiedDate(Integer id)
throws FinderException;

I don't get the class cast exception, but I also don't get the data I
expect. I get null instead. The debugging output returned is:

CachedImageBean.ejbHomeGetModifiedDate() - key: 1
CachedImageBean.ejbHomeGetModifiedDate(): null

So, for pk_blob_id = 1, the returned value is null. Below, you will
see that I do have a modified date in they table for pk_blob_id = 1.

I reiterate that using a return type of java.util.Date did work in
Resin-ee-3.0.7 and versions prior to that. And ejbSelectModifiedData
did properly return datetime data.

Please let me know if there is anything I can do or information I can
provide to help resolve this issue.

Notes
(0001690)
ferg   
01-02-07 12:50   
ejb/06df