tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Cheshire <cchesh...@bigredwire.com>
Subject Re: serializable class not persisting (long email)
Date Mon, 05 May 2003 21:00:52 GMT
Charlie,

I don't understand this at all. I have about 10 serializable classes, 
all coded in similar fashion. Every other one works, without exception, 
and they all contain far more than just String variables, including 
other customized serializable classes. This class does not persist until 
I place it in common/lib. I even repackaged it and put it in the same 
jar as my other support classes, and it still didn't work.

Why would the classloader instantiate new instances of it for one 
particular class when it is not doing it anywhere else?
My servlet creates an array, populates it, puts it in the session. 
Nothing fancy. Just what I am doing with other session variables.

I have repackaged it now in one of my packages as PieceOfSh*t.class. I 
have taken out clone() and toString() and it still doesn't work.

Now I am utterly confused. Can someone shed some light on whether this 
is because of tomcat or something really really really stupid I am doing 
programatically?

Chris

Cox, Charlie wrote:

>What is happening here is that your object is being serialized based upon
>the fact that it was originally loaded with WebAppClassloader (instanceA).
>When you try to deserialize with your newly created WebApp
>classloader(instanceB - from your manager reload or start/stop), then it is
>trying to resolve the class loaded through instanceA, which is not the same
>as your class loaded through instanceB, thus class not found.
>
>Now this differs from the 'Common' classloader in that the Common
>classloader never goes away and therefore is the same instance as before
>your reload and after. So when it needs to create a new instance of your
>class based upon the 'Common' classloader instance, it can.
>
>Charlie
>
>  
>
>>-----Original Message-----
>>From: Chris Cheshire [mailto:ccheshire@bigredwire.com]
>>Sent: Monday, May 05, 2003 3:11 PM
>>To: Tomcat Users List
>>Subject: Re: serializable class not persisting (long email)
>>
>>
>>The ONLY place it works is in common/lib. There is no extra instance 
>>floating around in the classpath either. I have verified that. 
>>Stopping/starting the context instead of reloading it yields the same 
>>exact problem. All of a sudden the classloader can't find the class, 
>>when it could while displaying a page.
>>
>>Completely bewildered,
>>
>>Chris
>>
>>Filip Hanik wrote:
>>
>>    
>>
>>>hmm, looks like a tomcat problem for sure. what happens if 
>>>      
>>>
>>you stop the
>>    
>>
>>>context and the start it again, instead of initiating a reload.
>>>
>>>does that make a difference?
>>>
>>>putting the classes in common/lib is not a good solution if 
>>>      
>>>
>>you want to
>>    
>>
>>>update them without stopping tomcat
>>>
>>>Filip
>>>
>>> 
>>>
>>>      
>>>
>>>>-----Original Message-----
>>>>From: Chris Cheshire [mailto:ccheshire@bigredwire.com]
>>>>Sent: Monday, May 05, 2003 11:55 AM
>>>>To: Tomcat Users List
>>>>Subject: Re: serializable class not persisting (long email)
>>>>
>>>>
>>>>Hi Yoav,
>>>>
>>>>Shapira, Yoav wrote:
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>Howdy,
>>>>>It doesn't seem like the problem is in the actual
>>>>>serializing/de-serializing of the class.  You don't get a
>>>>>readObject/writeObject exception nor a SerializationException.
>>>>>
>>>>>It seems like the class is not found during session archive
>>>>>de-serialization.  Try putting the jar with the class in it in
>>>>>common/lib instead of WEB-INF/lib and see if that makes a 
>>>>>          
>>>>>
>>difference.
>>    
>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>I tried moving the class into the jar used for all my other 
>>>>        
>>>>
>>serializable
>>    
>>
>>>>objects (shared between multiple apps), and it didn't find them.
>>>>&*%^^% I moved the jar into common/lib like you suggested 
>>>>        
>>>>
>>and it worked,
>>    
>>
>>>>but nothing else did. Why? My other serializable classes are in the
>>>>WEB-INF/lib and they work fine. Putting them into the common/lib
>>>>directory is not a feasible solution as the filesystem 
>>>>        
>>>>
>>permissions do
>>    
>>
>>>>not allow it (tomcat is owned by root).
>>>>
>>>>I am completely confused. Tomcat finds the class when compiling and
>>>>accessing the JSPs and servlets, just not while persisting. Is there
>>>>something wrong with the class name that it is causing a 
>>>>        
>>>>
>>clash somewhere?
>>    
>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>Also, the [Lextras.SearchResult indicates an attempt to 
>>>>>          
>>>>>
>>de-serialize an
>>    
>>
>>>>>array of SearchResult items, not just one SearchResult 
>>>>>          
>>>>>
>>instance.  This
>>    
>>
>>>>>is fine, just wanted to make sure you were aware of it.
>>>>>
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>Yes it is an array. I was curious at that notation. I tried 
>>>>        
>>>>
>>reloading
>>    
>>
>>>>the context when an array of different objects was in the 
>>>>        
>>>>
>>session and
>>    
>>
>>>>they persisted and reloaded just fine.
>>>>
>>>>
>>>>What can I do to fix this?
>>>>
>>>>Thanks
>>>>
>>>>Chris
>>>>
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message