David,
I still prefer this discussion to happen on the list...
> I'm running in JBoss 4.03, and yes, it's returning a MessageType
Hmm.... I don't have recent JBoss experience, but things generally
work for me in Jetty/Tomcat/Geronimo/SunOne.
> what has changed since I upgraded to Cayenne 2.0?
The most recent versions (1.2 and 2.0) are using Thread.currentThread
().getClassLoader() for creating new objects. This is usually the
application ClassLoader in the web apps. You can debug that by
comparing the ClassLoader of your classes
(MessageType.class.getClassLoader()) and the ones returned by Cayenne
and see why they are different.
Andrus
On Oct 12, 2006, at 11:15 AM, David Norwood wrote:
> Andrus:
>
> I'm running in JBoss 4.03, and yes, it's returning a MessageType. I
> think
> you're right about the multiple classloaders. This didn't happen
> before;
> what has changed since I upgraded to Cayenne 2.0?
>
> -david
>
> -----Original Message-----
> From: Andrus Adamchik [mailto:andru..bjectstyle.org]
> Sent: Thursday, October 12, 2006 11:09 AM
> To: cayenne-use..ncubator.apache.org
> Cc: David Norwood
> Subject: Re: ClassCastException in DataObject types
>
> David,
>
> So what type is returned from this method (if you remove the cast)?
> If it is still MessageType, than looks like an issue with multiple
> ClassLoaders, specific to your environment. Are you running this in a
> web container? What version of Cayenne is this?
>
> Andrus
>
> P.S. doesn't look like your address is subscribed to the list, so you
> won't receive any replies not cc'd to you.
>
>
> On Oct 12, 2006, at 1:52 AM, David Norwood wrote:
>> Hi,
>>
>>
>>
>> I've been using DataObjects with Cayenne for several years. After
>> porting to
>> MSSQL, I'm now encountering a very strange problem. The class below
>> represents a table called MessageType. I access it with this call:
>>
>>
>>
>> public static MessageType getMessageType(Integer id,
>> DataContext ctx)
>>
>> throws
>> CayenneRuntimeException, Exception {
>>
>> //MessageType linfo = (MessageType)
>> DataObjectUtils.objectForPK(ctx, MessageType.class, id.intValue());
>>
>> ObjectId oid = new ObjectId
>> ("MessageType",
>> MessageType.ID_PK_COLUMN, id);
>>
>> //this constructor implicitly uses
>> "CACHE_REFRESH" policy, so a fresh object will be returned
>>
>> ObjectIdQuery query = new
>> ObjectIdQuery(oid);
>>
>> MessageType linfo = (MessageType)
>> DataObjectUtils.objectForQuery(ctx, query);
>>
>> return linfo;
>>
>> }
>>
>>
>>
>> Both the .objectForPK() and the .objectForQuery return a
>> ClassCastException
>> on the MessageType (below); this never happened before. I can't for
>> the life
>> of me imagine what is happening.
>>
>>
>>
>> -david norwood
>>
>>
>>
>> Caused by: com.virtuant.mobilitee.exception.ServiceException:
>> com.virtuant.mobilitee.exception.ServiceException:
>> java.lang.ClassCastException: com.virtuant.mobilitee.db.MessageType
>>
>> at
>> com.virtuant.mobilitee.helper.DroolsHelper.getWorkingMemory
>> (DroolsHelper.jav
>> a:85)
>>
>> at
>> com.virtuant.mobilitee.ejb.RuleControllerBean.getUserList
>> (RuleControllerBean
>> .java:161)
>>
>> ... 73 more
>>
>> Caused by: com.virtuant.mobilitee.exception.ServiceException:
>> java.lang.ClassCastException: com.virtuant.mobilitee.db.MessageType
>>
>> at
>> com.virtuant.mobilitee.helper.DroolsHelper.getRule
>> (DroolsHelper.java:174)
>>
>> at
>> com.virtuant.mobilitee.helper.DroolsHelper.getRule
>> (DroolsHelper.java:127)
>>
>> at
>> com.virtuant.mobilitee.helper.DroolsHelper.getWorkingMemory
>> (DroolsHelper.jav
>> a:75)
>>
>> ... 74 more
>>
>> Caused by: java.lang.ClassCastException:
>> com.virtuant.mobilitee.db.MessageType
>>
>> at
>> com.virtuant.mobilitee.helper.DBHelper.getMessageType(DBHelper.java:
>> 400)
>>
>> at
>> com.virtuant.mobilitee.helper.DBHelper.getMessageType(DBHelper.java:
>> 372)
>>
>> at
>> com.virtuant.mobilitee.helper.DroolsHelper.getRule
>> (DroolsHelper.java:165)
>>
>> ... 76 more
>>
>> package com.virtuant.mobilitee.db.auto;
>>
>>
>>
>> import java.util.List;
>>
>>
>>
>> /** Class _MessageType was generated by Cayenne.
>>
>> * It is probably a good idea to avoid changing this class manually,
>>
>> * since it may be overwritten next time code is regenerated.
>>
>> * If you need to make any customizations, please use subclass.
>>
>> */
>>
>> public class _MessageType extends
>> com.virtuant.mobilitee.common.DBObject {
>>
>>
>>
>> public static final String FILENAME_PROPERTY = "filename";
>>
>> public static final String NAME_PROPERTY = "name";
>>
>> public static final String PROCESSID_PROPERTY = "processid";
>>
>> public static final String URL_PROPERTY = "url";
>>
>> public static final String INBOX_ARRAY_PROPERTY = "inboxArray";
>>
>> public static final String OUTBOX_ARRAY_PROPERTY = "outboxArray";
>>
>> public static final String TO_RULE_PROPERTY = "toRule";
>>
>>
>>
>> public static final String ID_PK_COLUMN = "ID";
>>
>>
>>
>> public String getFilename() {
>>
>> return (String)readProperty("filename");
>>
>> }
>>
>>
>>
>>
>>
>> public String getName() {
>>
>> return (String)readProperty("name");
>>
>> }
>>
>>
>>
>>
>>
>> public Integer getProcessid() {
>>
>> return (Integer)readProperty("processid");
>>
>> }
>>
>>
>>
>>
>>
>> public String getUrl() {
>>
>> return (String)readProperty("url");
>>
>> }
>>
>>
>>
>>
>>
>> public void addToInboxArray(com.virtuant.mobilitee.db.Inbox
>> obj) {
>>
>> addToManyTarget("inboxArray", obj, true);
>>
>> }
>>
>> public void removeFromInboxArray
>> (com.virtuant.mobilitee.db.Inbox obj) {
>>
>> removeToManyTarget("inboxArray", obj, true);
>>
>> }
>>
>> public List getInboxArray() {
>>
>> return (List)readProperty("inboxArray");
>>
>> }
>>
>>
>>
>>
>>
>> public void addToOutboxArray(com.virtuant.mobilitee.db.Outbox
>> obj) {
>>
>> addToManyTarget("outboxArray", obj, true);
>>
>> }
>>
>> public void removeFromOutboxArray
>> (com.virtuant.mobilitee.db.Outbox obj)
>> {
>>
>> removeToManyTarget("outboxArray", obj, true);
>>
>> }
>>
>> public List getOutboxArray() {
>>
>> return (List)readProperty("outboxArray");
>>
>> }
>>
>>
>>
>>
>>
>>
>>
>> public com.virtuant.mobilitee.db.Rule getToRule() {
>>
>> return (com.virtuant.mobilitee.db.Rule)readProperty
>> ("toRule");
>>
>> }
>>
>
>
>
>
> __________ NOD32 1.1798 (20061011) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>
This archive was generated by hypermail 2.0.0 : Thu Oct 12 2006 - 11:21:31 EDT