Thursday, July 4, 2019

ADF JSF : ADFc: Scope object serialization failed (object not serializable) and Managed Bean , Backing Bean

When I was testing I noticed on web logic EM logs that there is constant exception coming every second.


Download Code from Here , After Download go to TestSer.java and remove Serializable and run code you will notice below exception and then implement serializable this exception will be gone.

image

Let me demo you precisely why this happened.

Backing Bean

This is actually BackingBean which has one to one relationship with each and every component in java file.

image

It has getter and setter for each component on GUI.

image

Here is sample GUI and if you double click button it will allow you to create action inside this backing bean.

image

Also, before running please don’t forget to set following java option.

image

org.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION – This check is disabled by default. It checks no unserializable state content on session attributes is detected
After running application when I clicked button , it simply printed button called without any exception’

image

Managed Bean : Practice in ADF

Generally In ADF Development developer will not create backing bean for each and every JSF , JSFF. he will instead create one Managed Bean for whole TaskFlow consisting of multiple JSFF. Each JSFF page will call that managed bean to perform it operation.

image

So I created new Managed Bean (TestSer.java) and bind it to second button then ran the application without Serializable implemented in TestSer bean it was throwing above exception from both button.

but when I implemented Serializable in TestSer.java then it stopped throwing above exception from both button.

Note:- I did not implements Serializable in backingBean TestSerialization.java.

image

So please make sure you implements Serializable in this type of Managed bean॥

When you are designing an application to run in a clustered environment, you must:
Ensure that all managed beans with a life span longer than one request are serializable (that is, they implement the java.io.Serializable interface). Specifically, beans stored in session scope, page flow scope, and view scope need to be serializable.

No comments:

Post a Comment