Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

What is serialVersionUID?

Thread view: 
RC - 29 Jun 2005 13:24 GMT
import javax.servlet.*;
import javax.servlet.http.*;

public class MyClass extends HttpServlet {
....
}

 warning: [serial] serializable class MyClass has no definition of
                                ^
serialVersionUID
public class MyClass extends HttpServlet {

What is this warning message mean?
How do I get rid it?

Thank Q very much in advance!

P.S. I know a warning message is NOT an error, but
someday, sometime may be cause run time failure.
Ingo R. Homann - 29 Jun 2005 13:52 GMT
Hi,

> import javax.servlet.*;
> import javax.servlet.http.*;
[quoted text clipped - 9 lines]
>
> What is this warning message mean?

You need a serialVersionId, if your class implements "Serializable".
HttpServlet does so, and so you need such an id. (It is used, if the
Servlet-Context is relaunched and your sessions should be made
persistant / restored. If you do not need this feature, you do not need
a serialVersionId.)

> How do I get rid it?

There is some switch to disable the warning (e.g. in Eclipse...)

> P.S. I know a warning message is NOT an error, but
> someday, sometime may be cause run time failure.

Yes, its better not to ignore warnings (although that's not possible
with Java5 :-()

Ciao,
ingo
blaine@worldweb.com - 29 Jun 2005 15:41 GMT
You'll need to add a serialVersionUID to your class eg:

public class MyClass extends HttpServlet{
    public static final long serialVersionUID = 1L;

    public MyClass(){
   }
}
Skip - 29 Jun 2005 15:53 GMT
> You'll need to add a serialVersionUID to your class eg:
>
[quoted text clipped - 4 lines]
>     }
> }

That static field may be private too.
Bryce - 29 Jun 2005 16:06 GMT
>Hi,
>
[quoted text clipped - 27 lines]
>Yes, its better not to ignore warnings (although that's not possible
>with Java5 :-()

Added note:

If you are using Eclipse, it can generate the id for you. Click on the
yellow lightbulb.

--
now with more cowbell
Roedy Green - 30 Jun 2005 07:23 GMT
>serialVersionUID

see http://mindprod.com/jgloss/serialization.html

Signature

Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes

Roedy Green - 29 Aug 2005 08:13 GMT
>serialVersionUID
>public class MyClass extends HttpServlet {
>
>What is this warning message mean?
>How do I get rid it?

see http://mindprod.com/jgloss/serialization.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.