pavithraCS
pavithraCS

Reputation: 691

XMLDecoder returns null pointer exception

My application is a client server application. An object of type class A, is encoded using java.beans.XMLEncoder in client side and saved in database. Class A is located in client side. I need to decode that object at server side. When I try to use java.beans.XMLDecoder, xmlDecoder.readObject() method returns null. May be because class A is not present in server side. Is there a way to fix this?

Upvotes: 0

Views: 193

Answers (2)

user207421
user207421

Reputation: 310957

Yes, you need the classes concerned at the receiver.

The XML Decoder/Encoder classes aren't much use unless you install exception handlers on them both so you can see exactly what is going wrong. Otherwise they just do silly things like swallow exceptions and return null.

Upvotes: 1

Ezzored
Ezzored

Reputation: 925

Yes, you need the class A on server side too. Whenever you want to send/receive data, you need to have the sent/received classes in both locations: on the server and in the client too.

Simply copy class A to the server!

Upvotes: 1

Related Questions