java.io.InvalidClassException: local class incompatible: stream classdes

 
Re: ava.io.InvalidClassException: local class incompatible: stream classdes   
Feb 29, 2008 2:25 AM (reply 15 of 19)

Click to email this message

 
My Java version is the 1.5.0_14 and the value -3126998878902358585L comes from a solution that I read in a forum. The class that I'm trying to use is:
import java.util.Date;

public class DateExtendido extends Date {

static final long serialVersionUID = -3126998878902358585L;

public Date date=null;

public DateExtendido(){
super();
}

public DateExtendido(Date d){
super();
date = d;
}
}

I'm use it in this lines:

try{
DateExtendido inicioDesdeEx = new DateExtendido(inicioDesde);
out.writeObject(inicioDesdeEx);
DateExtendido inicioHastaEx = new DateExtendido(inicioHasta);
out.writeObject(inicioHastaEx);
}
catch(Exception e){
e.printStackTrace(System.out);
}

...

DateExtendido inicioDesdeEx = null;
try{
inicioDesdeEx = (DateExtendido)in.readObject();
inicioDesde = inicioDesdeEx.date;

DateExtendido inicioHastaEx = (DateExtendido)in.readObject();
inicioHasta = inicioHastaEx.date;
}catch(Exception e){
e.printStackTrace(System.out);
}

And the error:

java.io.InvalidClassException: java.util.Date; local class incompatible: stream classdesc serialVersionUID = 7523895402267505689, local class serialVersionUID = 7523967970034938905
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at dumbo7.user.FiltroUsuario.readObject(FiltroUsuario.java:348)
at dumbo7.user.FiltroUsuario.importFiltro(FiltroUsuario.java:436)
at dumbo7.user.DumboUser.setPersonalData(DumboUser.java:250)
at dumbo7.user.DumboUser.<init>(DumboUser.java:69)
at dumbo7.inicio.GestorInicio.loginDumbo(GestorInicio.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at atica.frameweb.manager.ManagerModule.doMethod(ManagerModule.java:611)
at atica.frameweb.manager.ManagerModule.doObjectDBMethod(ManagerModule.java:371)
at atica.frameweb.manager.ManagerModule.doObject(ManagerModule.java:261)
at atica.frameweb.manager.ManagerModule.doActions(ManagerModule.java:201)
at atica.frameweb.manager.HttpServletManager.service(HttpServletManager.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:420)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:134)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)

 
ibancg
Posts:1
Registered: 3/4/08
Re: ava.io.InvalidClassException: local class incompatible: stream classdes   
Mar 4, 2008 4:35 AM (reply 16 of 19)

Click to email this message

 
Hi, I was having this error.

Take a look at the hex representation of both serial uids:

7523895402267505689: 0x686A3F014B597400
7523967970034938905: 0x686A81014B597400

The 0x3F was changed by a 0x81.

In my case this behaviour was caused (only in MS Windows) by a string proccessing of the serialized object stream before unmarshall the object. A proccessing like that:

byte[] processedSerializedObjectByteArray = serializedObjectByteArray.toString().replace( ..., ... ).getBytes();

I fixed the problem with binary replace instead of using the String API, wich causes the replacement of 0x3F characters into 0x81 (only in MS Windows).
Are you doing a similar string proccessing?
 
ejp
Posts:15,588
Registered: 5/11/97
Re: ava.io.InvalidClassException: local class incompatible: stream classdes   
Mar 4, 2008 2:07 PM (reply 17 of 19)

Click to email this message

 
Also @OP I can't see what value the DateExtendido class is adding ...
 
relicary
Posts:4
Registered: 2/25/08
Re: ava.io.InvalidClassException: local class incompatible: stream classdes   
Mar 5, 2008 5:53 AM (reply 18 of 19)

Click to email this message

 
Hi,

I'm tried another way. Cos the java.util.Date don't works anyway, I'm save it as a String using DateFormat. The String type don't need the serialVersionUID.
 
ejp
Posts:15,588
Registered: 5/11/97
Re: ava.io.InvalidClassException: local class incompatible: stream classdes   
Mar 5, 2008 2:04 PM (reply 19 of 19)

Click to email this message

 
See reply #16. The 0x81 is the only byte with the high bit set and it is the only byte which is being corrupted. This clearly indicates that you are corrupting the stream somewhere, possibly by using a Reader or Writer, or converting it to and from a String. If you don't fix that problem it will come back and bite you somewhere else.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值