0

In my j2ee (myfaces + spring) application I have a session managed bean called UserSessionBean where I stored the data about the logged user.

That class is marked as Serializable

In a method I have to retrieve an HttpRequest parameter and i'm using HttpServletRequest:

public class UserSessionBean implements Serializable {

    public String getLang() {

HttpServletRequest req = (HttpServletRequest) FacesContext
            .getCurrentInstance().getExternalContext().getRequest();
    String sessUsr = req.getHeader("PARAMETER");
  }

I got an exception on WebSphere Application Server saying that the class is not Serializable.

How can I fix this?

user2010955
  • 3,871
  • 7
  • 34
  • 53
  • 1
    What's the exception stack trace? The above only gets a header from the HTTP request. Why would serializability of UserSessionBean, which is not involved at all in the above code, cause any trouble? – JB Nizet Feb 04 '14 at 12:19
  • The error I got is "Failed to replicate attribute UserSessionBean". Reading online I got that the reason could be that I use HttpServletRequest inside my Serializable sessionBean, that is not serializable... – user2010955 Feb 04 '14 at 12:31
  • You need to post your UserSessionBean code – IndoKnight Feb 04 '14 at 14:28
  • I already posted. UserSessionBean is a really small class with a method which includes the HttpServletRequest ... Anyway I'm going to add some details if you want – user2010955 Feb 04 '14 at 14:47
  • any ideas or suggestions? – user2010955 Feb 05 '14 at 12:03

0 Answers0