Example usage for javax.naming NamingException printStackTrace

List of usage examples for javax.naming NamingException printStackTrace

Introduction

In this page you can find the example usage for javax.naming NamingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.openiam.idm.srvc.synch.service.generic.LdapAdapterForGenericObject.java

public Response testConnection(SynchConfig config) {
    try {/*from   ww  w  .  j a v  a  2 s.c  o m*/
        if (connect(config)) {
            closeConnection();
            Response resp = new Response(ResponseStatus.SUCCESS);
            return resp;
        } else {
            Response resp = new Response(ResponseStatus.FAILURE);
            resp.setErrorCode(ResponseCode.FAIL_CONNECTION);
            return resp;
        }
    } catch (NamingException e) {
        e.printStackTrace();
        log.error(e);

        Response resp = new Response(ResponseStatus.FAILURE);
        resp.setErrorCode(ResponseCode.FAIL_CONNECTION);
        resp.setErrorText(e.getMessage());
        return resp;
    }
}

From source file:com.ikon.util.MailUtils.java

/**
 * /*from   ww w .j  a  v a2  s .  co m*/
 */
private static Session getMailSession() {
    Session mailSession = null;

    try {
        InitialContext initialContext = new InitialContext();
        Object obj = initialContext.lookup(Config.JNDI_BASE + "mail/openkm");
        mailSession = (Session) PortableRemoteObject.narrow(obj, Session.class);
    } catch (javax.naming.NamingException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return mailSession;
}

From source file:com.heliumv.factory.impl.FertigungCall.java

@Override
public void bucheMaterialAufLos(LosDto losDto, BigDecimal menge, boolean bHandausgabe,
        boolean bNurFehlmengenAnlegenUndReservierungenLoeschen, boolean bUnterstuecklistenAbbuchen,
        ArrayList<BucheSerienChnrAufLosDto> bucheSerienChnrAufLosDtos, boolean throwExceptionWhenCreate)
        throws RemoteException {
    try {/*from   www  .ja  va2 s .  co m*/
        getFac().bucheMaterialAufLos(losDto, menge, bHandausgabe,
                bNurFehlmengenAnlegenUndReservierungenLoeschen, bUnterstuecklistenAbbuchen,
                globalInfo.getTheClientDto(), bucheSerienChnrAufLosDtos, throwExceptionWhenCreate);
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

From source file:eu.learnpad.simulator.mon.probe.GlimpseAbstractProbe.java

/**
 * This constructor allow to create a GlimpseAbstractProbe object<br />
 * providing the {@link Properties} settings object
 * @param settings can be generated automatically
 * using {@link Manager#createConsumerSettingsPropertiesObject(String, String, String, String, String, String, boolean, String)}.
 * /*  www .  j  a v a 2  s.c  om*/
 */
public GlimpseAbstractProbe(Properties settings) {

    try {
        initContext = this.initConnection(settings, true);
        this.createConnection(initContext, settings.getProperty("probeChannel"), settings, true);
    } catch (NamingException e) {
        e.printStackTrace();
    } catch (JMSException e) {
        e.printStackTrace();
    }
}

From source file:org.openbmp.db_rest.helpers.AuthenticationService.java

/**
 * Initialize the class Sets the data source
 *
 * @throws//from w w w .j  a v a 2  s.c o m
 */

public AuthenticationService() {
    InitialContext initctx = null;
    try {

        initctx = new InitialContext();
        mysql_ds = (DataSource) initctx.lookup("java:/comp/env/jdbc/MySQLDB");

    } catch (NamingException e) {
        System.err.println("ERROR: Cannot find resource configuration, check context.xml config");
        e.printStackTrace();
    }
}

From source file:edu.byu.wso2.apim.extensions.BYUIdentifiersLookup.java

public void init(SynapseEnvironment synapseEnvironment) {
    if (log.isInfoEnabled()) {
        log.info("Initializing BYUIdentifiersLookup Mediator");
    }//ww  w  .  j a  v  a  2s  .com
    if (log.isDebugEnabled())
        log.debug("BYUIdentifiersLookup: looking up datasource" + DsName);
    try {
        this.ds = (DataSource) new InitialContext().lookup(DsName);
    } catch (NamingException e) {
        e.printStackTrace();
    }
    if (log.isDebugEnabled())
        log.debug("BYUIdentifiersLookup: acquired datasource");

}

From source file:de.tuttas.util.LDAPUtil.java

/**
 * Benutzer aus der LDAP Abfragen/*w w  w . j  ava 2s  .c o m*/
 *
 * @param username Benutzername
 * @param password Kennwort
 * @return der Benutzer
 * @throws Exception Wenn etwas schief ging
 */
public LDAPUser authenticateJndi(String username, String password) throws Exception {
    // Anbindung ans LDAP
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    props.put(Context.PROVIDER_URL, Config.getInstance().ldaphost);
    props.put(Context.SECURITY_PRINCIPAL, Config.getInstance().bindUser);//adminuser - User with special priviledge, dn user
    props.put(Context.SECURITY_CREDENTIALS, Config.getInstance().bindPassword);//dn user password
    try {
        context = new InitialDirContext(props);
        ctrls = new SearchControls();
        ctrls.setReturningAttributes(new String[] { "description", "mail", "sn", "initials", "givenName",
                "memberOf", "userPrincipalName", "distinguishedName" });
        ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    } catch (NamingException ex) {
        Logger.getLogger(LDAPUtil.class.getName()).log(Level.SEVERE, null, ex);
    }
    NamingEnumeration<javax.naming.directory.SearchResult> answers = context
            .search(Config.getInstance().userContext, "(cn=" + username + ")", ctrls);
    Log.d("answers=" + answers);
    Log.d("answers=" + answers.hasMore());

    if (!answers.hasMore()) {
        return null;
    }

    javax.naming.directory.SearchResult result = answers.nextElement();

    try {
        for (NamingEnumeration ae = result.getAttributes().getAll(); ae.hasMore();) {
            Attribute attr = (Attribute) ae.next();
            Log.d("attribute: " + attr.getID());

            /* print each value */
            for (NamingEnumeration e = attr.getAll(); e.hasMore(); System.out.println("value: " + e.next()))
                ;
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }

    String inititials = "";
    if (result.getAttributes().get("initials") != null) {
        inititials = result.getAttributes().get("initials").getAll().next().toString();
    }
    LDAPUser u;
    if (result.getAttributes().get("mail") == null) {
        u = new LDAPUser(result.getAttributes().get("sn").getAll().next().toString(),
                result.getAttributes().get("givenName").getAll().next().toString(), "", inititials);
    } else {
        u = new LDAPUser(result.getAttributes().get("sn").getAll().next().toString(),
                result.getAttributes().get("givenName").getAll().next().toString(),
                result.getAttributes().get("mail").getAll().next().toString(), inititials);
    }

    String dName = result.getAttributes().get("distinguishedName").getAll().next().toString();
    Log.d("dName=" + dName);
    if (dName.contains("OU=Lehrer")) {
        Log.d("Ich bin ein Lehrer");
        u.setRole(Roles.toString(Roles.LEHRER));
    } else {
        Log.d("Ich bin ein Schler");
        u.setRole(Roles.toString(Roles.SCHUELER));
        if (result.getAttributes().get("memberOf") != null) {
            String memberOf = result.getAttributes().get("memberOf").getAll().next().toString();
            String courseName = memberOf.split(",")[0];
            courseName = courseName.substring(courseName.indexOf("=") + 1);
            Log.d("Name der Klasse ist " + courseName);
            u.setCourse(courseName);
        }
    }

    String user = result.getNameInNamespace();

    try {

        props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        props.put(Context.PROVIDER_URL, Config.getInstance().ldaphost);
        props.put(Context.SECURITY_PRINCIPAL, user);
        props.put(Context.SECURITY_CREDENTIALS, password);

        context = new InitialDirContext(props);
    } catch (Exception e) {
        return null;
    }
    return u;
}

From source file:com.swdouglass.joid.server.DirectoryUserManagerImpl.java

public DirectoryUserManagerImpl() {
    try {/*from ww  w .j ava  2  s. c o  m*/
        initialCtx = DirectoryUtil.getInitialDirContext();
    } catch (NamingException ex) {
        log.warn("Could not create initial diretory context! " + ex);
        ex.printStackTrace();
    }
}

From source file:com.jaspersoft.jasperserver.war.CSVServlet.java

private DataSource getDataSource(HttpServletRequest req) {
    MondrianDrillThroughTableModel model = getDrillThroughModel(req);
    String dataSourceName = model.getDataSourceName();
    try {//from  w w w.j ava2 s.  c o m
        return (DataSource) getJndiContext().lookup(dataSourceName);
    } catch (NamingException e) {
        e.printStackTrace();
        log.error(e);
    }
    return null;
}

From source file:edu.byu.wso2.helper.BYUEntityHelper.java

public BYUEntityHelper() {
    try {/*from  w w  w.java 2s.  c o  m*/
        if (ds == null) {
            if (log.isDebugEnabled())
                log.debug("CustomTokenGenerator: looking up  datasource");

            ds = (DataSource) new InitialContext().lookup("jdbc/BYUPRODB");

            if (log.isDebugEnabled())
                log.debug("acquired datasource");
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }
}