- This topic has 12 replies, 2 voices, and was last updated 18 years, 3 months ago by Thomas Bednarz.
-
AuthorPosts
-
Thomas BednarzMemberDoes anyone know of a convenient way to create SUIDs for JavaBeans implementing the Serializable Interface? I consider the tool serialver which comes with the JDK very UNCONVENIENT since you have to pass the entire classpath manually for every bean! According to the documentation it is recommended to define the SUIDs in code rather then let the compiler generate it. Also Eclipse generates a warning if it cannot find a declaration such as
static final long serialVersionUID = {the generated SUID}L;
I guess there should be a tool in Eclipse/MyEclipse to perform this operation since JavaBeans are used a lot in Web Applications and JavaBeans that remain in Session Scope should definitely be serializable. Unfortunately I did not find something. So what is the recommended way to do this?
Any hint would be greatly appreciated.
Tom
Riyad KallaMemberHighlight the warning and either use CTRL-1 or use the quick fix to perform a “Generate” for the SUID.
Thomas BednarzMemberHmmm.., I found this solution yesterday but it gives me an error and always returns 1L for all classes!
The error is: The archive: /MapOnAirLib/MapOnAirLib.jar which is referenced by the classpath, does not exist.
This library is something I have written and which is used in several of my classes. They just compile fine. What I do NOT understand is the path! It is not stored in a directory called /MapOnAirLib! For deployment it is in WEB-INF\lib as a JAR file. The IDE includes the JAR file from a different directory on the harddisk, basically it is in a different Eclipse project.
So I guess that this path is wrong but I have no idea, how it composes this path!
After that error MyEclipse generates the following code:
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = 1L;It does this in every class!
Do you have any idea, what I should check?
Many thanks.
Tom
Riyad KallaMemberTo clarify, the JDT is providing this functionalty, MyEclipse doesn’t instrument the Java editor.
Is your error a runtime error a compilation error? If it’s a compilation error (which it looks like) I’d suggest you clean our your build path and make sure it’s correct, possibly removing any stale entries or ones marked with exclamation points.
Thomas BednarzMemberHello Riyad,
No it is not a compilation error. The app compiles and runs fine!
The message box with the above mentionned error message appears when I highlite the warning message and click ‘Quick fix’ and then select ‘add generated serial version id’. If I select ‘add default serial version id’ it works without error message but adds 1L as value for servialVersionUID.
I don’t know what JDT does but it seems it likes to calculate the hash depending on what is in my class and does for whatever reason NOT find this library.
I probably number the IDs myself, if I do not find a solution.
Tom.
Riyad KallaMemberTom,
From what you said and how I understand it now, this is a popup error when you try and generate a real SUID for your class, correct? No idea why this is popping up to be honest… does your class reference anything from that JAR?If you check your project Build Path under Libraries, do any of the libraries have exclamation points next to them?
Thomas BednarzMemberI searched Google, and I found that this seems to be a known bug. I currently run 3.1.1 and will upgrade to 3.1.2. I also found some statements, that the bug appears again in 3.2…! So I have to try and error….
Tom
Riyad KallaMemberVery strange, keep us posted. Thanks for doing some research to get to the bottom of this.
Thomas BednarzMemberUnfortunately the upgrade to 3.1.2 did not help at all.
In my .classpath file I have:
<classpathentry sourcepath=”D:/Projects/Eclipse/Libraries/MapOnAirLib/src” kind=”lib” path=”D:/Projects/Eclipse/Libraries/MapOnAirLib/MapOnAirLib.jar”/>
I still get this popup error ‘The archive: /MapOnAirLib/MapOnAirLib.jar which is referenced by the classpath, does not exist.’
So this path is not correct but I have no idea why. Of course there are no exclamation points etc. But I think this tool starts a new JVM and it looks very much like it would not take over the classpath or other environment variables correctly. Somewhere I read something like it is dependent on the order…..
I probably post this on a Eclipse forum.
Tom
Riyad KallaMemberOpen windows explorer, copy and paste that path: D:/Projects/Eclipse/Libraries/MapOnAirLib/MapOnAirLib.jar
into it, and hit enter. Does it work?
Thomas BednarzMemberYes it does, the jar is opened in my winzip program!
Tom
Riyad KallaMemberVery frustrating, I’m not sure what to say.
Thomas BednarzMemberFinal followup to this topic.
I posted the question in the Eclipse forum. To summarize the discussion here the outcomings:
a) this feature seems to be rarely used. People seem to disable the warning in the IDE configuration.
b) Those who do NOT want to disable warnings create their own numbering scheme, usually in a very simple way: starting at 1 and increase by 1 for every new class and version.This is what I proposed earlier, so I think there is not more to say about it.
Cheers
Tom
-
AuthorPosts