Re: ClassCastException when it should work anyway



Ross Bamford wrote:
> On Sun, 2005-05-29 at 00:32 +0200, Jimi Hullegård wrote:
>> Chris Smith wrote:
>>> Short answer: no.
>>>
>>> A class in Java is identified by two pieces of information, a fully
>>> qualified class name and a class loader. Each class loader
>>> effectively defines its own class namespace, so that even if two
>>> classes have
>>> exactly the same fully qualified name ("community.login.User") for
>>> example, if they were loaded by different class loaders then they
>>> are still not the same.
>>
>> Thank your for that clear and straight answer. I think I understand
>> now.
>>
>>> Is changing servlet containers an option? What container are you
>>> using now?
>>
>> I'm using Orion (www.orionserver.com). And though changing servlet
>> container is possible, I would prefer not to have to go thr through
>> that hassle.
>>
>> But I'm starting to think that I should focus on the main problem,
>> and maybe you can help me with that?
>> Because the thing is, I'm having problems registering logouts on a
>> community I'm building (a test site, at the moment). Everything
>> works when the logged in user clicks on logout, and when when a
>> regular time out happens. But if I for instance recompile the
>> servlet when orion is running, or make some changes in some
>> xml-file, then then _some_ users get logged out completely (which is
>> OK), while others not get logged out completely (logout time not
>> written to the database).
>> So I would like to write a function that runs every five minutes (or
>> whatever) and goes thrue all active sessions, retrieves the
>> corresponding user object, and compares the the ones who is logged
>> in according to the database.
>> But the thing is I can't find any way to get hold of all active
>> sessions. I have looked everywhere... Any ideas?
>
> You're confusing your container with running changes. Do this with a
> development machine in particular circumstances *if you must* but not
> ever with a production machine.
>
> Imagine you write a program that includes all kinds of complex class
> manipulation stuff to make sure that the right classes are available
> at
> the right time. You have multiple boxes for your classes, and use
> clever stuff like lazy init and bytecode caching. It'll all work
> transparently, since the bytecode will be the same no matter which
> box loads it, right?
>
> Until someone changes the bytecode after the caches have started to
> fill up.

Well, I have already solved the main problem, without manipulating with
class loaders or bytecodes. I now keep track of all active sessions (using a
session listener), and I have written a "tidy up" function that fixes any
incomplete logouts.

/Jimi


.



Relevant Pages

  • getting class object using custom class loader
    ... bytecode of a class "Test" is stored in the database. ... Through custom class loader, I get the Class object for this class ...
    (comp.lang.java.developer)
  • custom class loader question
    ... bytecode of a class "Test" is stored in the database. ... Through custom class loader, I get the Class object for this class ...
    (comp.lang.java)