Hello Vladimir,
Thank you for your help.
And I'm still have some questions.
Why do we need to implement "some interface"? java.io.Serializable I
think? But anyway I implemented this interface - it doesn't work. This
approach works for EJB. :)
And my question is: Is there any way to use "some shared" object with
reloadable servlets without Tomcat restart?
Thanks.
Wednesday, March 14, 2001, 3:16:45 PM, you wrote:
VG> I think you're experiencing a standard Java class loader problem.
VG> Java treats classes loaded into different classloaders as different
VG> classes, even though they share the same full. qual. name.
VG> Your recompiled servlets are reloaded by a brand new class loader
VG> to make sure the old classes are garbage collected. What you get
VG> from the context is actuially an instance of a class loaded into
VG> a different classloader, and (StatesBean) part in your statement
VG> causes StatesBean to be loaded again by this new classloader that
VG> reloaded your servlet, so
VG> VM complains that you cannot cast objects since it thinks they
VG> are instances of 2 completely different classes. No matter where
VG> you place your files you'll have the same problem.
VG> You can avoid this problem by writing some extra code and have your
VG> bean to implement some interface.... Extra work, just restart
VG> Tomcat every time...
VG> Regards,
VG> VG.
VG> Andrey Myatlyuk wrote:
>>
>> Hello Tomcat users,
>>
>> I'm in a trouble. I share some object(StatesBean) between servlets. And when I
>> recompile _servlet_, I got ClassCastException about shared object.
>>
>> _statesBean=
>> (StatesBean)getServletContext().getAttribute(StatesBean.STATES_BEAN_NAME);
>>
>>
>> Classfile for this object is placed in the same directory, where
>> servlets do - web-inf/classes. Where I need to place classfile for
>> this object to prevent Tomcat exceptions?
>>
>> Of course, if I reload Tomcat everything is OK.
>>
>> Thank you in advance!
>>
>> --
>> Best regards,
>> Andrey mailto:[EMAIL PROTECTED]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, email: [EMAIL PROTECTED]
VG> ---------------------------------------------------------------------
VG> To unsubscribe, e-mail: [EMAIL PROTECTED]
VG> For additional commands, email: [EMAIL PROTECTED]
--
Best regards,
Andrey mailto:[EMAIL PROTECTED]