Hi,
I am getting this exception while deploying my web application. It is occuring for the attributes which I have set for the session. Here is the method which sets the session attribues :---- -
protected void showIndexPage(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException{
-
-
PrintWriter out = response.getWriter();
-
HttpSession session = request.getSession(true);
-
response.setContentType("text/html;charset=UTF-8");
-
System.out.println("Inside showIndexPage() method");
-
-
DAOFactory mysqlFactory = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
-
System.out.println("below DAOFactory object------------->>");
-
OffshoreResourceDAO offshoreResourceDAO = mysqlFactory.getOffshoreResourceDAO();
-
Vector offshoreResourceVOList = offshoreResourceDAO.getResource();
-
-
ClientResourceDAO clientResourceDAO = mysqlFactory.getClientResourceDAO();
-
Vector clientResourceVOList = clientResourceDAO.getClientResource();
-
-
WorkPackageDetailsDAO workPackageDetailsDAO = mysqlFactory.getWorkPackageDetailsDAO();
-
Vector workPackageDetailsList = workPackageDetailsDAO.getWorkPackageDetails();
-
System.out.println("WorkPackageDetails are:"+workPackageDetailsList);
-
-
Vector weekList = weekFinder();
-
System.out.println("Week List is:"+weekList);
-
-
session.setAttribute("OffshoreResourceList",offshoreResourceVOList);
-
session.setAttribute("ClientResourceList", clientResourceVOList);
-
session.setAttribute("WorkPackageDetailsList", workPackageDetailsList);
-
session.setAttribute("WeekList", weekList);
-
request.getRequestDispatcher("index.jsp").forward(request,response);
-
-
out.close();
-
}
-
The attributes for which I am getting this exception are OffshoreResourceList,ClientResourceList,WorkPackag eDetailsList. All these are Vectors.While throwing exception, this warning is comin:--- -
WARNING: Cannot serialize session attribute OffshoreResourceList for session 5F8A4B888C40A6D0C72FB2B67A60A641
-
How I can remove this exception.
Thanks and regards,
madhoriya
11 33361
Make your OffshoreResourceList et al implement the Serializable interface. This
is extremely easy because that interface doesn't define any methods, so simply
do this: -
public class OffshoreResourceList implements Serializable {
-
...
-
}
-
Do the same for all the other classes that can't be serialized now.
kind regards,
Jos
Make your OffshoreResourceList et al implement the Serializable interface. This
is extremely easy because that interface doesn't define any methods, so simply
do this: -
public class OffshoreResourceList implements Serializable {
-
...
-
}
-
Do the same for all the other classes that can't be serialized now.
kind regards,
Jos
Hi Jos,
It's Ok. But I have read the Vector class documentation...It already implements the serializabe interface. Then why we have to serialize it again in this class
Thanks and regards,
madhoriya
Hi Jos,
It's Ok. But I have read the Vector class documentation...It already implements the serializabe interface. Then why we have to serialize it again in this class
Thanks and regards,
madhoriya
Ah, ok, then the error diagnostic indicates that one of the members you've put
in that Vector doesn't implement the Serializable interface. I didn't know that
your class was a Vector itself.
kind regards,
Jos
Ah, ok, then the error diagnostic indicates that one of the members you've put
in that Vector doesn't implement the Serializable interface. I didn't know that
your class was a Vector itself.
kind regards,
Jos
Hi Jos,
Then what i have to do to remove this exception. See what I am putting in this vector is object of a Value Object class.... which is made of getters and setters methods.
These objects contains the values fetched from the database means every object has his ints, strings, double etc....
Thanks and regards,
madhoriya
Hi Jos,
Then what i have to do to remove this exception. See what I am putting in this vector is object of a Value Object class.... which is made of getters and setters methods.
These objects contains the values fetched from the database means every object has his ints, strings, double etc....
Thanks and regards,
madhoriya
It's simple: -
public class ValueObject implements Serializable {
-
...
-
}
-
The ObjectInputStream and ObjectOutputStream explicitly check whether or not
a to be serialized object implements that interface; if not: *boink* they throw
that Exception.
So basically, an object (or a class) is Serializable if it implements the Serializable
interface itself and all of its members are Serializable too; primitives are always
Serializable.
kind regards,
Jos
It's simple: -
public class ValueObject implements Serializable {
-
...
-
}
-
The ObjectInputStream and ObjectOutputStream explicitly check whether or not
a to be serialized object implements that interface; if not: *boink* they throw
that Exception.
So basically, an object (or a class) is Serializable if it implements the Serializable
interface itself and all of its members are Serializable too; primitives are always
Serializable.
kind regards,
Jos
Hi Jos,
Got it !! Thanks ...
regards,
madhoriya
Hi Jos,
Got it !! Thanks ...
regards,
madhoriya
You're welcome of course; does it work now?
kind regards,
Jos
ps. You could write a little article about it of course; put it in the Editor's Corner
where I take care of the typos so we can put it in the Java Articles section
afterwards. Just a concise article about Serialization not a (verbatim) copy of
the text in the API documentation ...<hint hint/>
You're welcome of course; does it work now?
kind regards,
Jos
ps. You could write a little article about it of course; put it in the Editor's Corner
where I take care of the typos so we can put it in the Java Articles section
afterwards. Just a concise article about Serialization not a (verbatim) copy of
the text in the API documentation ...<hint hint/>
Hi Jos,
Yep it worked. I vil think about your suggestion. Problem is work load.
Thanks and regards,
madhoriya
Hi Jos,
Yep it worked. I vil think about your suggestion. Problem is work load.
Thanks and regards,
madhoriya
Take it easy; there's no pressure or time limit. Writing a good article under
pressure had never succeeded before.
kind regards,
Jos
Take it easy; there's no pressure or time limit. Writing a good article under
pressure had never succeeded before.
kind regards,
Jos
Hi Jos,
Again Thanks for ur suggestion.
I vil surely do it when i vill be free minded. I really want to do it
thanks and regards,
madhoriya
Hi Jos,
Again Thanks for ur suggestion.
I vil surely do it when i vill be free minded. I really want to do it
thanks and regards,
madhoriya
Thanks for your good intentions; I appreciate it a lot; and realize: there's no
hurry and we both can take care of any hurdles if that are any. It can be a nice
article.
kind regards,
Jos
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
2 posts
views
Thread by Michael |
last post: by
|
reply
views
Thread by Ravi Tallury |
last post: by
|
1 post
views
Thread by ptaz |
last post: by
|
11 posts
views
Thread by DrUg13 |
last post: by
|
reply
views
Thread by Markus Wollny |
last post: by
|
reply
views
Thread by mailkhurana |
last post: by
|
5 posts
views
Thread by TZESENG |
last post: by
|
1 post
views
Thread by David Van D |
last post: by
| | | | | | | | | | | |