6 Replies Latest reply on Jul 8, 2016 12:13 PM by maeste

    How to shutdown IronJacamar embedded properly ?

    sewatech

      Hi,

       

      When I shutdown IronJacamar embedded, some non-daemon threads are kept alive. That's a real problem when I try to embed IJ in a webapp.

       

      Here is the simpler exemple that shows my problem :

      public static void main(String[] args) throws Throwable {
      
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.LocalOnlyContextFactory");
         System.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      
         Set<Thread> initialThreads = Thread.getAllStackTraces().keySet();
      
         Embedded embedded = EmbeddedFactory.create();
         embedded.startup();
         embedded.shutdown();
      
         Set<Thread> finalThreads = Thread.getAllStackTraces().keySet();
         finalThreads.removeAll(initialThreads);
      
         finalThreads.forEach(thread -> System.out.println(thread.getThreadGroup().getName() + "/" + thread.getName()));
      }
      
      

       

      Is their a way to initialize or shutdown IJ in order to avoid this thread problem ?

       

      Alexis