🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7216

Re: ClassCastException that doesn't make sense

#7216
From: Lifeng
Date: Tue, 03 Jul 2001 17:19
46 lines
2892 bytes
This is a very important point. I have a feeling that this might well be
where the problem comes. For some other reason though, I can't test it
right away, but I still would like to know if this is the problem, what I
can do to fix it or what is the way around it.

Thank you so much for your help!

Lifeng

"John McGrath [TeamB]" wrote:

> On Tue, 03 Jul 2001 09:39:30 -0500, Lifeng wrote:
>
> > The obj.getClass().getName() returns the right name with full
> > qualified path name. However, obj instanceof NewEnrolleeOTW
> > returns false.
> >
> > It can't be caused by different classes with the same name --
> > there is only one package contains class NewEnrolleeOTW in
> > the whole project. FYI, this NewEnrolleeOTW is a serilazable
> > object that passed from a calling object into an EJB. The
> > exception occurred in the EJB.
>
> In addition to the the package name and the class name, the identity of
> a class includes the ClassLoader that loaded it.  Is it possible that
> the object was instantiated using a class from a different ClassLoader
> than the code doing the testing?  In that case, the object *is* of a
> different class.  "instanceof" will return false and a cast will fail.
>
> I am not an expert on EJBs, but I do know that EJB containers use
> multiple ClassLoader instances to keep code separate.
>
> Try evaluating the following expression in that context:
>
>    obj.getClass().getClassLoader() == NewEnrolleeOTW.getClassLoader()
>
> If this evaluates to false, then that is your problem.
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3B41FEA0.E10C9D77@gocentrics.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.190.198.17!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews
References: <3B414660.789CD256@telocity.com> <3b41572c$1_1@dnews> <u3d8e4hg3.fsf@sds.no> <3b4194be$1_2@dnews> <3B41D922.53A88264@gocentrics.com> <MPG.15abb6d46a9afe9c98a31d@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9bba90999259f167
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-07-03 10:06:29 PST
Message-ID: <3B41FEA0.E10C9D77@gocentrics.com>
Date: Tue, 03 Jul 2001 12:19:28 -0500
From: Lifeng <lifeng@gocentrics.com>
X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: ClassCastException that doesn't make sense
References: <3B414660.789CD256@telocity.com> <3b41572c$1_1@dnews> <u3d8e4hg3.fsf@sds.no> <3b4194be$1_2@dnews> <3B41D922.53A88264@gocentrics.com> <MPG.15abb6d46a9afe9c98a31d@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 207.247.42.2
X-Trace: dnews 994179226 207.247.42.2 (3 Jul 2001 09:53:46 -0700)
Lines: 47
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.190.198.17!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews