2 Replies Latest reply: May 22, 2008 7:05 PM by 807581 RSS

    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.