private static DataServiceManager getDataServiceManager(GenericApplicationContext ctx) { DataServiceManager mgr = null; try { String[] beanNames = ctx.getBeanNamesForType(DataServiceManager.class, true, false); if (beanNames == null || 1 != beanNames.length) { throw new WMRuntimeException( com.wavemaker.common.MessageResource.NO_DATA_SERVICE_MGR_BEAN_FOUND, Arrays.toString(beanNames)); } mgr = (DataServiceManager) ctx.getBean(beanNames[0]); } catch (RuntimeException ex) { try { ctx.close(); } catch (Exception ignore) { } throw ex; } return new SpringDataServiceManagerWrapper(mgr, ctx); }