• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

weird InvalidClassException

 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have developed a small notepad applet that (supposedly)saves notes remotely using RMI.

I noticed the known RMI firewall problems, so instead of using http tunnelling i found out the javaranchcommon.jar and started making changes.

Now, my problem is a bit weird. When i try to connect to a servlet and retireve a Document object it does so successfully however when i try from within my applets I get an Invalid Class Exception from class HTTP, from method sendAndRecv , the complete exception follows:



HTTP: java.io.InvalidClassException: javax.swing.text.AbstractDocument; local class incompatible: stream classdesc serialVersionUID = -116069779446114664, local class serialVersionUID = 6842927725919637215



furthermore i have developed a wrappper for document class named remotedocument that also extends serializable as well as an implementation remotedocument.

The Objects send are remote document or remotedocumentImpl or Document so I found it weird that i Get AbstractDocument in the exception and that i get the exception from http and not from one of my classes...

Here are the two different ways i use the sendAndreceive.

1)works:


2)fails:

menu applet and notepad are two different applets

Any suggestions??

Thank you in advance

pinda
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

HTTP: java.io.InvalidClassException: javax.swing.text.AbstractDocument; local class incompatible: stream classdesc serialVersionUID = -116069779446114664, local class serialVersionUID = 6842927725919637215

This error is caused by having different versions of your class being accessed by your client and server. When you build your app, make sure that you refresh the classes used by both. Also check your server's classpath to make sure that old classes aren't getting picked up somewhere.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pinda,

Also
1. http://java.sun.com/developer/TechTips/2000/tt0229.html
2. http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/serialver.html
3. http://jguru.com/faq/view.jsp?EID=5063

Links might be helpful in understanding more about concept of serial version ids.

More you can search on google..

Regards
Maulin
[ March 16, 2005: Message edited by: Maulin Vasavada ]
 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and thank you for the replies.

I run the serialver command and from the workspace in eclipse classes in web-inf and from the extracted jar i got the exact same serial version.


com.ext.portlet.notepad.transferable.RemoteDocument: static final long serial VersionUID = 100991064940334783L;

com.ext.portlet.notepad.transferable.RemoteDocumentImpl: static final long serial VersionUID = -3875362439486193205L;


however it worries me the fact that the exception contains "AbstractDocument" Since Im not using that object anywhere...
I implement Document and inherit from plainDocument

Could it be because my applets are signed?(the transferable classes though are in a different jar...)
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serializing Swing components only works if the versions on each end are compatible. If you go look at the Javadoc for pretty much every Swing class, you'll see that it contains a special note about this. Here's the text from the "AbstractDocument" class itself:


Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.


So unless your applet and servlet are running in the exact same JVM version, this problem is expected.
 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically My tests are locally on the same machine.

Furthermore, when I was using rmi in my remote tests, were included several and different vms all working fine.

So this message is kind of strange.

Anyway I'll have a better look to check what you say.

But still its strange using an applet it fails when using the same code from within an application class it works!!!
 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally problem was solved by changing the object that i wanted to transfer from document to stringbuffer.

Thank you all for the replies.

pinda
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic