try {  System.out.println("*********************************************"); System.out.println("Resolving ServiceManagerLocalHome"); System.out.println("*********************************************"); System.out.println("*********************************************"); ServiceManagerLocalHome serviceManagerLocalHome = (ServiceManagerLocalHome) EJBHomeFactory .getInstance().lookupLocalHome( "Fenix/ServidorAplicacao/ServiceManagerLocal", ServiceManagerLocalHome.class); System.out.println("*********************************************"); System.out.println("Using local ejb service manager calls."); System.out.println("*********************************************"); System.out.println("*********************************************"); service = serviceManagerLocalHome.create(); } catch (Exception e) {  System.out.println("*********************************************"); System.out .println("Couldn't find Local EJB... Resolving remote ServiceManagerHome"); System.out.println("*********************************************"); System.out.println("*********************************************");  try {  ServiceManagerHome serviceManagerHome = (ServiceManagerHome) EJBHomeFactory .getInstance().lookupHome( "Fenix/ServidorAplicacao/ServiceManager", ServiceManagerHome.class); System.out .println("*********************************************"); System.out.println("Using remote ejb service manager calls."); System.out .println("*********************************************"); System.out .println("*********************************************"); service = serviceManagerHome.create(); } catch (Exception e2) { System.out .println("*********************************************"); e2.printStackTrace(); System.out .println("*********************************************"); System.out .println("*********************************************"); } }  if (service == null) try { System.out .println("*********************************************"); System.out.println("No ejb's found - trying directly..."); System.out .println("*********************************************"); System.out .println("*********************************************"); Class serviceMagagerBeanClass = Class .forName("ServidorAplicacao.ServiceManagerBean"); service = (IServiceManagerWrapper) serviceMagagerBeanClass .getConstructor(null).newInstance(null); System.out .println("*********************************************"); System.out.println("Using local service manager calls."); System.out .println("*********************************************"); System.out .println("*********************************************"); } catch (Exception e1) { service = null; } }
try { service = createServiceManager( "Fenix/ServidorAplicacao/ServiceManagerLocal", ServiceManagerLocalHome.class); } catch (Exception e) { try { service = createServiceManager( "Fenix/ServidorAplicacao/ServiceManager", ServiceManagerHome.class); } catch (Exception e2) { try { Class serviceMagagerBeanClass = Class .forName("ServidorAplicacao.ServiceManagerBean"); service = (IServiceManagerWrapper) serviceMagagerBeanClass .getConstructor(null).newInstance(null); System.out.println("Using direct service manager calls."); } catch (Exception e1) { service = null; throw new RuntimeException("Unable to create any service manager.", e2); } } } }
	private void init()	{		if (service != null)		{			System.out.println("*********************************************");			System.out					.println("ServiceManager instance allready resolved... No need to resolv it again");			System.out.println("*********************************************");			System.out.println("*********************************************");			return;		}		try		{			//get the local reference to the session bean			System.out.println("*********************************************");			System.out.println("Resolving ServiceManagerLocalHome");			System.out.println("*********************************************");			System.out.println("*********************************************");			ServiceManagerLocalHome serviceManagerLocalHome = (ServiceManagerLocalHome) EJBHomeFactory					.getInstance().lookupLocalHome(							"Fenix/ServidorAplicacao/ServiceManagerLocal",							ServiceManagerLocalHome.class);			System.out.println("*********************************************");			System.out.println("Using local ejb service manager calls.");			System.out.println("*********************************************");			System.out.println("*********************************************");			service = serviceManagerLocalHome.create();		}		catch (Exception e)		{			System.out.println("*********************************************");			System.out					.println("Couldn't find Local EJB... Resolving remote ServiceManagerHome");			System.out.println("*********************************************");			System.out.println("*********************************************");						try			{				//get the remote reference to the session bean				ServiceManagerHome serviceManagerHome = (ServiceManagerHome) EJBHomeFactory						.getInstance().lookupHome(								"Fenix/ServidorAplicacao/ServiceManager",								ServiceManagerHome.class);				System.out						.println("*********************************************");				System.out.println("Using remote ejb service manager calls.");				System.out						.println("*********************************************");				System.out						.println("*********************************************");				service = serviceManagerHome.create();			}			catch (Exception e2)			{				System.out						.println("*********************************************");				e2.printStackTrace();				System.out						.println("*********************************************");				System.out						.println("*********************************************");			}		}		if (service == null)				try				{					System.out							.println("*********************************************");					System.out.println("No ejb's found - trying directly...");					System.out							.println("*********************************************");					System.out							.println("*********************************************");					Class serviceMagagerBeanClass = Class							.forName("ServidorAplicacao.ServiceManagerBean");					service = (IServiceManagerWrapper) serviceMagagerBeanClass							.getConstructor(null).newInstance(null);					System.out							.println("*********************************************");					System.out.println("Using local service manager calls.");					System.out							.println("*********************************************");					System.out							.println("*********************************************");				}				catch (Exception e1)				{					service = null;				}	}