11

I have a class serializable in a so big project coded without specify serialVersionUID, and save in a dataBase MySQL as a blob!

I have to add some fields to this class, but after doing this, I get an exception like this:

IOException: error when reading object
org.datanucleus.exceptions.NucleusUserException:
IOException: error when reading object at
org.datanucleus.store.rdbms.datatype.BlobImpl.getObject(BlobImpl.java:134)

.
. 
..

Caused by: java.io.InvalidClassException:
local class incompatible: stream classdesc serialVersionUID = 1113799434508676095,
local class serialVersionUID = -8504143738844344601 at
java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:560)

This is all the stackTrace:

IOException: error when reading object
org.datanucleus.exceptions.NucleusUserException: IOException: error when reading object
at org.datanucleus.store.rdbms.datatype.BlobImpl.getObject(BlobImpl.java:134)
at      org.datanucleus.store.rdbms.mapping.AbstractLargeBinaryRDBMSMapping.getObject(AbstractLargeB    inaryRDBMSMapping.java:271)
at     org.datanucleus.store.mapped.mapping.SingleFieldMapping.getObject(SingleFieldMapping.java:21    9)
at org.datanucleus.store.rdbms.fieldmanager.ResultSetGetter.fetchObjectField(ResultSetGetter.java:153)
at org.datanucleus.state.AbstractStateManager.replacingObjectField(AbstractStateManager.java:1197)
at com.xxxxxxxx.xxxxxxxx.ra.impl.RAOrganizationRecordImpl.jdoReplaceField(RAOrganizationRecordImpl.java)
at com.xxxxxxxx.xxxxxxxx.ra.impl.BaseRARecordImpl.jdoReplaceFields(BaseRARecordImpl.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2772)
at org.datanucleus.store.rdbms.query.PersistentIDROF$1.fetchFields(PersistentIDROF.java:441)
at org.datanucleus.state.JDOStateManagerImpl.loadFieldValues(JDOStateManagerImpl.java:841)
at org.datanucleus.state.JDOStateManagerImpl.initialiseForHollowAppId(JDOStateManagerImpl.java:284)
at org.datanucleus.state.StateManagerFactory.newStateManagerForHollowPopulatedAppId(StateManagerFactory.java:116)
at org.datanucleus.ObjectManagerImpl.findObjectUsingAID(ObjectManagerImpl.java:2117)
at org.datanucleus.store.rdbms.query.PersistentIDROF.getObjectForApplicationId(PersistentIDROF.java:435)
at org.datanucleus.store.rdbms.query.PersistentIDROF.getObject(PersistentIDROF.java:301)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.nextResultSetElement(ForwardQueryResult.java:130)
at org.datanucleus.store.rdbms.query.ForwardQueryResult$QueryResultIterator.next(ForwardQueryResult.java:282)
at org.datanucleus.jdo.JDOPersistenceManager.detachCopyAll(JDOPersistenceManager.java:1176)
at org.datanucleus.jdo.JDOPersistenceManagerProxy.detachCopyAll(JDOPersistenceManagerProxy.java:166)
at com.xxxxxxxx.xxxxxxxx.ra.impl.RAOrganizationStore.getRecords(RAOrganizationStore.java:136)
at com.xxxxxxxx.xxxxxxxx.ra.impl.RAOrganizationManagerImpl.getRecords(RAOrganizationManagerImpl.java:174)
at com.xxxxxxxx.xxxxxxxx.admin.actions.OrganizationAction.browse(OrganizationAction.java:246)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.UrlInterceptor.intercept(UrlInterceptor.java:47)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.MonitoringInterceptor.intercept(MonitoringInterceptor.java:47)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.TransactionInterceptor.intercept(TransactionInterceptor.java:36)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.ExceptionInterceptor.intercept(ExceptionInterceptor.java:34)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.io.InvalidClassException: com.xxxxxxxx.xxxxxxxx.ra.RAOrganization; local class incompatible: stream classdesc serialVersionUID = -1666617984322225572, local class serialVersionUID = 6311293439415161861
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:560)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1599)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1494)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1748)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1327)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
at org.datanucleus.store.rdbms.datatype.BlobImpl.getObject(BlobImpl.java:122)
... 102 more
Nested Throwables StackTrace:
java.io.InvalidClassException: com.xxxxxxxx.xxxxxxxx.ra.RAOrganization; local class incompatible: stream classdesc serialVersionUID = -1666617984322225572, local class serialVersionUID = 6311293439415161861
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:560)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1599)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1494)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1748)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1327)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
at org.datanucleus.store.rdbms.datatype.BlobImpl.getObject(BlobImpl.java:122)
at org.datanucleus.store.rdbms.mapping.AbstractLargeBinaryRDBMSMapping.getObject(AbstractLargeBinaryRDBMSMapping.java:271)
at org.datanucleus.store.mapped.mapping.SingleFieldMapping.getObject(SingleFieldMapping.java:219)
at org.datanucleus.store.rdbms.fieldmanager.ResultSetGetter.fetchObjectField(ResultSetGetter.java:153)
at org.datanucleus.state.AbstractStateManager.replacingObjectField(AbstractStateManager.java:1197)
at com.xxxxxxxx.xxxxxxxx.ra.impl.RAOrganizationRecordImpl.jdoReplaceField(RAOrganizationRecordImpl.java)
at com.xxxxxxxx.xxxxxxxx.ra.impl.BaseRARecordImpl.jdoReplaceFields(BaseRARecordImpl.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2772)
at org.datanucleus.store.rdbms.query.PersistentIDROF$1.fetchFields(PersistentIDROF.java:441)
at org.datanucleus.state.JDOStateManagerImpl.loadFieldValues(JDOStateManagerImpl.java:841)
at org.datanucleus.state.JDOStateManagerImpl.initialiseForHollowAppId(JDOStateManagerImpl.java:284)
at org.datanucleus.state.StateManagerFactory.newStateManagerForHollowPopulatedAppId(StateManagerFactory.java:116)
at org.datanucleus.ObjectManagerImpl.findObjectUsingAID(ObjectManagerImpl.java:2117)
at org.datanucleus.store.rdbms.query.PersistentIDROF.getObjectForApplicationId(PersistentIDROF.java:435)
at org.datanucleus.store.rdbms.query.PersistentIDROF.getObject(PersistentIDROF.java:301)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.nextResultSetElement(ForwardQueryResult.java:130)
at org.datanucleus.store.rdbms.query.ForwardQueryResult$QueryResultIterator.next(ForwardQueryResult.java:282)
at org.datanucleus.jdo.JDOPersistenceManager.detachCopyAll(JDOPersistenceManager.java:1176)
at org.datanucleus.jdo.JDOPersistenceManagerProxy.detachCopyAll(JDOPersistenceManagerProxy.java:166)
at com.xxxxxxxx.xxxxxxxx.ra.impl.RAOrganizationStore.getRecords(RAOrganizationStore.java:136)
at com.xxxxxxxx.xxxxxxxx.ra.impl.RAOrganizationManagerImpl.getRecords(RAOrganizationManagerImpl.java:174)
at com.xxxxxxxx.xxxxxxxx.admin.actions.OrganizationAction.browse(OrganizationAction.java:246)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.UrlInterceptor.intercept(UrlInterceptor.java:47)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.MonitoringInterceptor.intercept(MonitoringInterceptor.java:47)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.TransactionInterceptor.intercept(TransactionInterceptor.java:36)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.xxxxxxxx.xxxxxxxx.admin.interceptors.ExceptionInterceptor.intercept(ExceptionInterceptor.java:34)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Who have an idea about resolving this issue.

ATEF CHAREF
  • 387
  • 5
  • 8
  • 18
  • Can you show your original class and modified class, and some details about how you are persisting and recovering objects ? – emecas Dec 25 '14 at 14:31

2 Answers2

11

Define a member in the class concerned:

private static final long serialVersionUID = 1113799434508676095L;

This solves the problem described in the message, by forcing the serialVersionUID of the local class to match what was put in the stream when you serialized the old version of the class, which would have been computed automatically over various class attributes if no serialVersionUUD field was present at that time.

It is possible that you altered the class in an incompatible way, which will then produce a different exception. See the Object Serialization Specification chapter on Versioning for details. However merely adding or removing a field doesn't have that effect.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • you could actually explain *why* and *how* this would fix the issue, and given what constraints. – eis Dec 26 '14 at 10:37
  • this is also don't resolve the problem. – ATEF CHAREF Dec 26 '14 at 11:01
  • @user2604148 Are you sure you copy/pasted it correctly? And do you really get exactly the same exception? With exactly the same message? – user207421 Dec 26 '14 at 12:29
  • I add the stack Trace after implementation and trying to fix serialVersionUID, but I constate that stream classdesc serialVersionUID is generated each time and not fix – ATEF CHAREF Dec 26 '14 at 14:18
  • @ATEFCHAREF So why you accept this answer ??? i have the same problem , how did you solveit ? – mohammad Jul 12 '16 at 09:52
  • @mohammed Err, because it's the correct answer? Clearly his comment is now obsolete. – user207421 Jul 13 '16 at 03:17
  • @downvoter Don't kid yourself. – user207421 Jul 13 '16 at 03:36
  • you forget to add final keyword, use this: private static final long serialVersionUID = 1113799434508676095L; – Elmar Abbasov Dec 08 '16 at 06:18
  • @ElmarAbbasov Actually there is nothing in the Object Serialization Specification that specifically requires `final`, but it's required by the code in `ObjectStreamClass.getDeclaredSUID()`, which is curious. – user207421 Jan 20 '17 at 07:45
  • @ATEFCHAREF I would also like to know what you meant by 'constated', which is not a word in English, but if you're claiming that the `serialVersionUID' is always computed even when declared, you're mistaken. – user207421 Jul 11 '19 at 11:13
2

You can implement private void readObject(ObjectInputStream in) in your object class. It kinda "overrides" the default behavior, even though it is declared as "private", so technically it should not. Basically, when java serializer needs to read an object from a stream, of class that has this method implemented, it will call that instead of doing its default thing.

So, you can implement a logic into it, that will read all the existing fields from the stream, and assign default values to those that are missing.

Edit: As @EJP points out (thanks, @EJP!), this does not quite work. You also need to defineprivate static long serialVersionUID in your class, and set it to the "old" value you see in the exception.

Also, consider replacing Serializable with Externalizable for the future, it gives you some more flexibility, and transparency. Extending Externalizable tells java that you intend to handle serialization yourself, and it will then not attempt to do its default thing that throws the exception.

In that case, implement readExternal(ObjectInputStream in) to read members from the stream one-by-one, and initialize those that are missing to some kind of default.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Dima
  • 39,570
  • 6
  • 44
  • 70
  • where to implement readObject(ObjectInputStream in), I did'nt understand your response, can you explain? – ATEF CHAREF Dec 25 '14 at 15:50
  • The class that you modified, that implements `Serializable`. You can add a `readObject` method to it, and implement the custom logic there. – Dima Dec 25 '14 at 15:57
  • I add this: private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { identifier = (String) stream.readObject(); country = (String) stream.readObject(); dn = (String) stream.readObject(); orgUnit = (String) stream.readObject(); cn = (String) stream.readObject(); } but where I call this? it does'nt resolve the problem... – ATEF CHAREF Dec 26 '14 at 09:03
  • 1
    This won't fix the problem. The exception is thrown prior to invocation of this method if it exists. -1 – user207421 Dec 26 '14 at 09:06
  • @EJP indeed. I edited the answer to reflect your correction. Thanks for noticing! – Dima Dec 26 '14 at 11:20
  • @user2604148: you don't need to call it anywhere, java serialization will call the new method you added when it sees your class in the stream. I just edited my answer to explain why it does not resolve your problem: you need to also define `serialVersionUID` in your class. I forgot to mention that initially. Sorry about that. – Dima Dec 26 '14 at 11:23
  • sorry, this two does not fix the problem! I try to add the method and the old serial number... but same I have same exception always... and the method that I implemented was not invoked when debuging!! – ATEF CHAREF Dec 26 '14 at 11:57
  • If you get the same exception, that means that either the number you added is wrong or you added it to a wrong class, or declared it wrong. Look at the exception message closely, it has "local class serialVersionUID". It should be the number that you added, and it should also match "streamdesc serialVersionUID". – Dima Dec 26 '14 at 12:27
  • @Dima He doesn't 'also' need to define a `serialVersionUID`. That should be *all* he needs to do. According to his deleted answer all he's done is add three string fields. That doesn't need a `readObject()`method. – user207421 Dec 26 '14 at 12:27
  • @EJP, maybe, or maybe not. Depends on what are the fields he added, and how he wants them initialized. Deserialization does not invoke default constructors, so leaving new fields undefined may be a problem. – Dima Dec 26 '14 at 12:31
  • Initialization is a separate and possibly imaginary problem. The solution to *this* one is a `serialVersionUID` field, and *maybe*, for the possibly imaginary problem, 'also' a `readObject()` method. Not the other way round. – user207421 Dec 26 '14 at 12:36
  • @Dima No. Why do you ask? Or are you just trolling? – user207421 Jul 13 '16 at 03:16
  • @EJP it's been a while, but I don't remember asking you anything. Care to provide some context? – Dima Jul 13 '16 at 10:18
  • @Dima You asked whether I was a lawyer, but the moderators have been at it. – user207421 Jul 14 '16 at 06:54