Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

"Deserialization not allowed for class" error after Migrating to AEM 6.3

Avatar

Level 2

Hi,

I have an application object which is serialized and stored in the session and it is deserialized to retrieve the value.

This was originally implemented in AEM 6.1

Now i am trying to migrate the application to AEM 6.3 , here the same code during deserialization  is throwing "java.lang.UnsupportedOperationException: Deserialization not allowed for class "

Below is the code for deserialization

public static Object deserializeByteArray(final byte[] in) {

  ByteArrayInputStream bis = null;

  ObjectInputStream ois = null;

  try {

  bis = new ByteArrayInputStream(in);

  ois = new ObjectInputStream(bis);

  Object objectValue = (Object) ois.readObject();

  return objectValue;

  } catch (final ClassNotFoundException e) {

  LOG.error("Caught CNFE decoding " + in.length + " bytes of data ", e);

  } catch (final IOException e) {

  LOG.error("Caught IOException decoding " + in.length + " bytes of data ", e);

  } finally {

  closeSilently(bis);

  closeSilently(ois);

  }

  return null;

  }

6 Replies

Avatar

Level 10

Can you try running this without trying to store in a session. What line of code is throwing an error. This is just straight Java and should work in AEM.

Avatar

Level 2

I am getting error in Object objectValue = (Object) ois.readObject();

while attempting to readObject

Avatar

Level 10

Hard to say without knowing the class you are serializing; this sounds like a java concern. Make sure the class is serializable [1] .. maybe its some internal class that no longer implements Serializable?

[1] https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html

Avatar

Level 7

@priyadarshinic9395328 : +1 for this answer.. we have seen similar thing happening in 6.2..

Avatar

Level 2

Thank you so much , I was able to solve the issue following what was suggested.