You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Andy Gumbrecht <an...@orprovision.com> on 2010/03/30 17:34:32 UTC

Remote Shutdown

SimpleServiceManager.stop()  is not calling 'stop' on any RA

This lookup is throwing a NamingException, and thus never lists the 
adapters to close on shutdown:

namingEnumeration = 
containerSystem.getJNDIContext().listBindings("openejb/resourceAdapter");

Does anyone know the correct lookup string?

Andy

Re: Remote Shutdown

Posted by Andy Gumbrecht <an...@orprovision.com>.
Found already, this works - SimpleServiceManager.stop():

try {
             ContainerSystem containerSystem = 
SystemInstance.get().getComponent(ContainerSystem.class);
             NamingEnumeration<Binding> namingEnumeration = null;

             try {
                 namingEnumeration = 
containerSystem.getJNDIContext().listBindings("openejb/Resource");
             } catch (NamingException ignored) {
                 logger.debug("No resource adapters were created");
             }

             if (namingEnumeration != null) {

                 while (namingEnumeration.hasMoreElements()) {

                     Binding binding = namingEnumeration.nextElement();
                     Object object = binding.getObject();

                     if (object instanceof ResourceAdapter) {

                         ResourceAdapter resourceAdapter = 
(ResourceAdapter) object;

                         logger.debug("Stopping ResourceAdapter: " + 
binding.getName());

                         try {
                             resourceAdapter.stop();
                         } catch (Exception e) {
                             logger.fatal("ResourceAdapter Shutdown 
Failed: " + binding.getName(), e);
                         }
                     }
                 }

             } else {
                 logger.warning("No resources were found");
             }
         } catch (Throwable e) {
             logger.fatal("Unable to get ResourceAdapters from JNDI.  
Stop must be called on them for proper vm shutdown.", e);
         }