Monday, May 17, 2010

Serialize with care

To think serialization meant just implementing the Marker interface Serializable and just get on with life as usual. As if it would be that easy. What fun would that be right? So today i was breaking my web services to a separate EAR because of the need to load balance and fail over web services. In that i had an exception which was propagated from the EJB layer which was remotely deployed. It worked fine when running together within one app server. But in production after deployement it kept giving an error says org.jaxen.VariableContext class not found. I was speding around 1hr trying to figure out what was wrong by checking my application.xml, checking my libraries within the EAR. But i could not find a reason as to why it was giving this error.

After a few mins of googling about there was a JBOSS-JIRA issue mentioned which said that though JBoss AS throws that error, the real reason is that you have a class which is serialized but it does not have the default contructor because of the fact you override the default contructor with your own constructor. After going through my code i found that in one of my classes i had such a scenraio and also i had used ResourceBundle within that class which i had to make transient as well because it is not serializable.

So after adding the default constructor to my DTO which was passed i was able to resolve the issue.

Cheers

No comments:

Post a Comment