2 Replies Latest reply on May 23, 2008 12:05 AM by 807581

    ThreadLocal problem in Sun One 8.2

    807581
      I initialized an ThreadLocal in web tier, but it lost in EJB tier.
      public class Session {
              private static final ThreadLocal var = new ThreadLocal();
              ...
              public static Session initialize() {
                Session session = (Session) var.get();
                if (session == null) { 
                     session = new Session();
                     var.set(session);
                }
                
                return session;
           }
      
              public static Session currentSession() {
                Session session = (Session) var.get();
                if (session == null) {
                     throw new IllegalStateException(ERROR_SESSAO_INVALIDA);
                }
      
                return session;
           }
      When in EJBModule I try Session.currentSession() throws IllegalStateException cause session is null, but it was created in Web tier.

      This problem is not occuring in JBoss, but in Sun One 8.2 it is.

      Thanks for any help.