0 Replies Latest reply on Apr 28, 2015 10:24 AM by Steve Andrews

    Wildfly 8.2 ClassCastException on session attributes

    Steve Andrews Newbie

      Hi

       

      I am migrating some applications from AS7.1 to Wildfly 8.2. I have some legacy apps that store user details in the users session which work fine on AS7.1.

      On Wildfly, the application works ok when deployed for the first time. If I redeploy the application then I am getting ClassCastException when I try and retrieve the session attributes. I have to restart the server to fix the problem.

       

      The application stores the user details by:

           AccountProfile user = new AccountProfile();

           //populate the details from logon

           session.setAttribute("UserProfile", user);

       

      When it tries to retrieve the profile to handle requests using

           AccountProfile user = (AccountProfile) session.getAttribute("UserProfile");

       

      I get error: java.lang.ClassCastException: com.bhsf.website.shared.data.user.AccountProfile cannot be cast to com.bhsf.website.shared.data.user.AccountProfile

       

      The application is a simple war file with a few dependent jars. There is only 1 copy of AccountProfile in the classpath. Wildfly is just the basic standalone configuration with a few datasources and hosts defined, nothing else has changed. It looks like it's holding onto a previous version of the class somewhere between redeploys?

       

      Can anyone help?

      Thanks!