List of usage examples for javax.naming InitialContext InitialContext
public InitialContext() throws NamingException
From source file:demo.learn.shiro.util.SqlUtil.java
/** * Gets the JNDI {@link DataSource}. Look at * %webroot%/META-INF/context.xml./*from w ww. j ava 2 s. c om*/ * @return {@link DataSource}. */ public static DataSource getJndiDataSource() { if (null == _jndiDataSource) { try { Context context = new InitialContext(); _jndiDataSource = (DataSource) context.lookup(C.JNDI_DATASOURCE_NAME); } catch (Exception ex) { ex.printStackTrace(); } } return _jndiDataSource; }
From source file:br.ufac.sion.converter.CargoConverter.java
private CargoFacadeLocal lookupVagaFacadeLocal() { try {/*from ww w .jav a 2 s. co m*/ Context c = new InitialContext(); return (CargoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/CargoFacade"); } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }
From source file:br.ufac.sion.converter.InscricaoConverter.java
private InscricaoFacadeLocal lookupInscricaoFacadeLocal() { try {//from w w w . ja va 2 s. c om Context c = new InitialContext(); return (InscricaoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/InscricaoFacade"); } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }
From source file:br.ufac.sion.converter.ConcursoConverter.java
private ConcursoFacadeLocal lookupConcursoFacadeLocal() { try {//from w ww. j av a 2s . c o m Context c = new InitialContext(); return (ConcursoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/ConcursoFacade"); } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }
From source file:br.ufac.sion.inscricao.converter.CandidatoConverter.java
private CandidatoFacadeLocal lookupCidadeFacadeLocal() { try {/*from www . ja v a2 s .c o m*/ Context c = new InitialContext(); return (CandidatoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/CandidatoFacade"); } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }
From source file:jedai.domain.security.AclClassHome.java
protected SessionFactory getSessionFactory() { try {/* w w w.j a v a2s.c o m*/ return (SessionFactory) new InitialContext().lookup("SessionFactory"); } catch (Exception e) { log.error("Could not locate SessionFactory in JNDI", e); throw new IllegalStateException("Could not locate SessionFactory in JNDI"); } }
From source file:br.ufac.sion.converter.ContaConverter.java
private ContaBancariaFacadeLocal lookupVagaFacadeLocal() { try {/*from ww w . ja va 2 s .c o m*/ Context c = new InitialContext(); return (ContaBancariaFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/ContaBancariaFacade"); } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }
From source file:br.ufac.sion.converter.FuncionarioConverter.java
private FuncionarioFacadeLocal lookupFuncionarioFacadeLocal() { try {/* w w w . j ava 2 s . c om*/ Context c = new InitialContext(); return (FuncionarioFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/FuncionarioFacade"); } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }
From source file:com.duroty.lucene.parser.ParserFactory.java
/** * Creates a new instance of ParserFactory *///from w w w .j a va2s . co m public ParserFactory() { Map options = ApplicationConstants.options; try { Context ctx = new InitialContext(); this.parseFactoryConfig = (HashMap) ctx.lookup((String) options.get(Constants.PARSE_FACTORY_CONFIG)); } catch (Exception e) { this.parseFactoryConfig = new HashMap(); } }
From source file:com.commoncoupon.mail.EmailProcessor.java
/** * Retrieves a Mail session from Tomcat's Resource Factory (JNDI) *///from w w w. jav a2 s.co m protected Session getSession() { Session session = null; try { Context envCtx = (Context) (new InitialContext()).lookup("java:comp/env/"); session = (Session) envCtx.lookup("mail/Session"); /*If you get exception here remove activation.jar and mail.jar from web-inf lib *It should be present in only tomcat/lib */ log.info("Returning session"); } catch (NamingException ex) { log.error("cannot locate resource named 'mail/Session'.", ex); Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); // Get the Session object. session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("search2let@gmail.com", "Tol3t@dm!n321"); } }); } return session; }