Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

deserialize Doesn't work in WebLogic 6.1 sp2 Help

4 views
Skip to first unread message

Matthew

unread,
Feb 11, 2002, 5:12:39 PM2/11/02
to

I am Attempting to serialize and deserialize a stateful session bean. The deserialization
seems to be the problem. I have figured out that the line throwing the error is
the "readObject" line.

A similar problem was reported on Jan 31 2002, but the solution suggested deals
with the "getEJBObject" line. I have tryed to implement this solution, as you
can see below, but since the error I am getting is thrown before getting to that
line, it makes no difference.

The Exception I am getting is an "InvalidClassException". The message reads as
follows = "weblogic.rmi.internal. LocalServerRefMissing no-arg constructor for
class".

As far as the "no-arg constructor" error goes, as I understand it I should not
be having that problem. My Session bean implements the SessionBean interface and
does not explicitly extend anything, so by default it extends Object, right?!
Object has a no-args constructor, so there should be no problem.

My code is as follows:

---SERIALIZATION--- Handle msaHandle = contributions.getHandle(); ObjectOutputStream
toFile = new ObjectOutputStream( new FileOutputStream(handleFile)); toFile.writeObject(msaHandle);
toFile.close();

---DESERIALIZATION--- ObjectInputStream fromFile = new ObjectInputStream( new
FileInputStream(handleFile)); Handle msaHandle = (Handle) fromFile.readObject();
//MsaSession contributions = (MsaSession) msaHandle.getEJBObject(); MsaSession
contributions = (MsaSession) javax.rmi.PortableRemote Object.narrow(msaHandle.getEJBObject(),
MsaSession.class); fromFile.close();


I have tried to print "classname" (available in the InvalidClassException class),
but only get null as the value.

Anyone have any ideas?

Rob Woollen

unread,
Feb 11, 2002, 8:15:16 PM2/11/02
to
What are the member variable types in your sfsb?  Does it work if you have an empty bean?

I would suggest that you open a case with sup...@bea.com

-- Rob

-- 

----------------------------------------------------------------------

AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server

by Michael Girdley, Rob Woollen, and Sandra Emerson

http://learnWebLogic.com
 

Rajeev Dave

unread,
Feb 12, 2002, 5:54:30 AM2/12/02
to
try deleting all class files and then recompiling all the java source files

as according to javadocs this exception is thrown for one of these reasons
· The serial version of the class does not match that of the class
descriptor read from the stream
· The class contains unknown datatypes
· The class does not have an accessible no-arg constructor

The most common I find to be the first one

HTH

- Rajeev

Matthew <matthe...@tonservices.com> wrote in message
news:3c6841d7$1...@newsgroups.bea.com...

Rchandran

unread,
Mar 9, 2002, 2:05:43 PM3/9/02
to
I am facing exactly the same problem. I create a SFSB during a HTTP
session and save that serializing the information. But while
deserializing the SFSF, I run into the same problem. I have made sure:

1. The SFSB has a no-argument (empty) create (ejbCreate) method in
addition to others.

2. The classes for the member objects all have no-argument
constructors and serializable.

3. several times deleted and recompiled all classes and still getting
the same error.

The problem is with Weblogic 6.1 SP2.

If anybody has solved this problem, I would appreciate posting the
solution.

Rchandran

"Matthew" <matthe...@tonservices.com> wrote in message news:<3c6841d7$1...@newsgroups.bea.com>...

Martin

unread,
Mar 27, 2002, 7:39:14 AM3/27/02
to
Exactly the same problem :
We use Weblogic 6.1 sp2

In the same method :

// serialize
Handle handle = tc.getHandle();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(handle);
oos.flush();
String decoded_handle = baos.toString();
...

// deserialize
byte[] datas = decoded_handle.getBytes();
ByteArrayInputStream sbis = new ByteArrayInputStream(datas);
ObjectInputStream ois = new ObjectInputStream(sbis);
Handle handle2 = (Handle)ois.readObject(); // <-- Execption here

Exception :
java.io.InvalidClassException: java.lang.Long; Local class not
compatible: stream classdesc serialVersionUID=4290774032661291999
local class serialVersionUID=4290774380558885855
at java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)
at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)

Everything is clean in my classpath !!!
Any help ???

d...@dima.dhs.org

unread,
Mar 27, 2002, 4:15:06 PM3/27/02
to
It doesn't work because you convert byte array which contains serialized
Handle to and from String :

String decoded_handle = baos.toString();
...

byte[] datas = decoded_handle.getBytes();

and datas is not the same as baos.toString()

If you really need to store handle as String you can do something like this:

import javax.mail.internet.MimeUtility;

...


ByteArrayOutputStream baos = new ByteArrayOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(MimeUtility.encode(baos,"base64"));


oos.writeObject(handle);
oos.flush();
String decoded_handle = baos.toString();
...

byte[] datas = decoded_handle.getBytes();
ByteArrayInputStream sbis = new ByteArrayInputStream(MimeUtility.decode(datas,"base64"));


ObjectInputStream ois = new ObjectInputStream(sbis);
Handle handle2 = (Handle)ois.readObject();

> In the same method :

--
Dimitri

0 new messages