2 Replies Latest reply on Jun 4, 2013 3:54 AM by tonyweb

    InitialContext binding unexpected behavior after hot deploy ...

    Newbie

      Hi guys and girls,

      I'm a new GateIn portlet developer and I'm here to ask for your help.

       

      I'm using GateIn 3.5 on Tomcat 7.

      My need is to create an object in a thread (I'm using quartz-2.1.7.jar) and put it into InitialContext (so I can get it again using lookup from InitialContext).

       

      [code]

      // In Thread ...

      long tm = System.currentTimeMillis();

      String newVar = TestBindJNDIPortlet.VAR_TO_BIND_BASE + "_" + tm;

       

       

      InitialContext ctx = new InitialContext();

      ctx.bind(newVar, "" + tm);

       

       

      // Later in "portlet code" ...

      InitialContext ctx = new InitialContext();

      String readVal = (String) ctx.lookup(var);

      [/code]

       

       

       

      This way I can bind a value to InitialContext and read it without issues.

       

       

      However, when I hot-deploy the portlet again (even without modifications) and try to do again Bind+Read, I can bind the value (in thread) but from portlet I can't read it (NameNotFoundException)

      ... it seems I'm "using" two different InitialContext, one "seen" from the Thread and one "seen" from portlet code.

       

       

      Can anyone, please, tell me what am I missing?

       

       

      If this is the intended/normal behavior, is there a way to do what I'm trying to do?

      I'm forced to "register" the object in InitialContext since I'm using some code that looks up the "resource" from there.

       

       

      Thanks in advance and

       

       

      Best Regards,

      Antonio