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:com.ritchey.naming.InitialContextFactory.java

/**
 * Get Context that has access to default Namespace. This method won't be
 * called if a name URL beginning with java: is passed to an InitialContext.
 *
 * @see org.mortbay.naming.java.javaURLContextFactory
 * @param env a <code>Hashtable</code> value
 * @return a <code>Context</code> value
 *//*w w w . j  av  a  2  s.c o  m*/
public Context getInitialContext(Hashtable env) {
    Log.debug("InitialContext loaded");
    Context ctx = new localContextRoot(env);

    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("build.properties"));
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    Context jdbc = null;
    try {
        jdbc = ctx.createSubcontext("jdbc");
    } catch (NamingException e) {
        try {
            jdbc = (Context) ctx.lookup("jdbc");
        } catch (NamingException e1) {
            e1.printStackTrace();
        }
    }
    Context ldap = null;
    try {
        ldap = ctx.createSubcontext("ldap");
    } catch (NamingException e) {
        try {
            ldap = (Context) ctx.lookup("ldap");
        } catch (NamingException e1) {
            e1.printStackTrace();
        }
    }

    Log.debug("getInitialContext");

    String databaseNames = properties.getProperty("database.jndi.names");
    if (databaseNames == null) {
        Log.warn(new RuntimeException("database.jndi.names is not defined"
                + " in build.properties as a comma separated list in " + "build.properties"));
        return ctx;
    }

    for (String database : databaseNames.split(" *, *")) {
        Log.debug("create " + database);
        try {
            createDs(database, properties, jdbc);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    try {
        createLdapStrings(properties, ldap);
    } catch (NamingException e1) {
        e1.printStackTrace();
    }

    String url = getValue(false, "picture", null, properties);
    try {
        ctx.bind("picture", url);
    } catch (NamingException ex) {
        Logger.getLogger(InitialContextFactory.class.getName()).log(Level.SEVERE, null, ex);
    }

    try {
        Log.debug("jdbc initial context = " + ctx.listBindings("jdbc"));
        NamingEnumeration<Binding> ldapBindings = ctx.listBindings("ldap");
        Log.debug("ldap initial context = " + ctx.listBindings("ldap"));
        while (ldapBindings.hasMore()) {
            Binding binding = ldapBindings.next();
            Log.debug("binding: " + binding.getName());
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }
    return ctx;
}

From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java

public ArrayList<String> loadSurveysFromServerToEditor(String userName) throws MSMApplicationException {
    ArrayList<String> surveyList = new ArrayList<String>();

    InitialContext initialContext = null;

    try {//www.ja va2 s  .  c  o  m
        initialContext = new InitialContext();
    } catch (NamingException e) {
        e.printStackTrace();
    }

    UserManager userManager = null;

    try {
        userManager = (UserManager) initialContext.lookup("ndg-core/UserManagerBean/remote");
    } catch (NamingException e) {
        e.printStackTrace();
    }

    NdgUser user = null;

    try {
        try {
            if (userManager != null) {
                user = userManager.findNdgUserByName(userName);
            }
        } catch (MSMApplicationException e) {
            e.printStackTrace();
        }
    } catch (NoResultException e) {
        // empty
    }

    ArrayList<SurveyXML> userSurveyList = new ArrayList<SurveyXML>();

    try {
        userSurveyList = loadSurveysDB(user);
    } catch (MSMSystemException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < userSurveyList.size(); i++) {
        Survey survey = manager.find(Survey.class, ((SurveyXML) userSurveyList.toArray()[i]).getId());

        surveyList.add(survey.getSurveyXml().toString());
    }

    return surveyList;
}

From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java

public void saveSurveyFromEditorToServer(String userName, String surveyContent) throws MSMApplicationException {

    SurveyParser parser = new SurveyParser();
    StringBuffer buffer = new StringBuffer(surveyContent);

    InitialContext initialContext = null;
    UserManager userManager = null;/*  w  w w  .j  av  a2s .  co m*/
    NdgUser user = null;
    SurveyXML survey = null;

    try {
        initialContext = new InitialContext();
        userManager = (UserManager) initialContext.lookup("ndg-core/UserManagerBean/remote");
        if (userManager != null) {
            user = userManager.findNdgUserByName(userName);
        }
        survey = parser.parseSurvey(buffer, "UTF-8");
    } catch (NamingException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
        throw new SurveyNotParsedException();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        throw new SurveyNotParsedException();
    } catch (IOException e) {
        e.printStackTrace();
        throw new SurveyNotParsedException();
    }

    if ((survey != null) && (user != null)) {
        try {
            if (MD5.checkMD5Survey(buffer, survey.getChecksum())) {
                Survey currentSurvey = manager.find(Survey.class, survey.getId());
                if (currentSurvey != null) {
                    updateSurvey(user, survey, buffer);
                } else {
                    persistSurvey(user, survey, buffer);
                }
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            throw new SurveyNotParsedException();
        } catch (IOException e) {
            e.printStackTrace();
            throw new SurveyNotParsedException();
        }
    } else {
        throw new SurveyNotRecordedException();
    }
}

From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java

public void sendSlicedSurvey(NdgUser userLogged, String idSurvey, ArrayList<String> listOfDevices)
        throws MSMApplicationException, MSMSystemException {
    for (String deviceNumber : listOfDevices) {
        SurveySmsSlicer surveySMSSlicer = new SurveySmsSlicer(userLogged.getUserAdmin(), idSurvey,
                deviceNumber);/*from w w  w  .  j a v a  2s.com*/
        ArrayList<SMSMessageVO> arrayOfSMS = surveySMSSlicer.getSlicedSurvey();

        for (SMSMessageVO smsMessageVO : arrayOfSMS) {
            smsMessageVO.port = SMSModemHandler.SMS_NDG_PORT;
            businessDelegate.sendSMS(smsMessageVO);
        }

        TransactionLogVO tl = new TransactionLogVO();
        tl.setDtLog(new Timestamp(System.currentTimeMillis()));

        InitialContext initialContext = null;
        IMEIManager imeiManager = null;

        try {
            initialContext = new InitialContext();
            imeiManager = (IMEIManager) initialContext.lookup("ndg-core/IMEIManagerBean/remote");
        } catch (NamingException e) {
            e.printStackTrace();
        }

        ImeiVO imeivo = imeiManager.findImeiByMsisdn(deviceNumber);

        tl.setUser(userLogged.getUsername());
        tl.setImei(imeivo.getImei());
        tl.setSurveyId(idSurvey);
        tl.setStatus(TransactionLogVO.STATUS_SUCCESS);
        tl.setTransactionType(TransactionLogVO.TYPE_SEND_SURVEY);
        tl.setTransmissionMode(TransactionLogVO.MODE_SMS);

        // log the transaction status, as SUCCESS, when sending a survey by SMS
        TransactionLogManager transactionlogManager = null;

        try {
            transactionlogManager = (TransactionLogManager) initialContext
                    .lookup("ndg-core/TransactionLogManagerBean/remote");
        } catch (NamingException e) {
            e.printStackTrace();
        }

        if (transactionlogManager != null) {
            transactionlogManager.logTransaction(tl);
        }
    }
}

From source file:com.ca.dvs.app.dvs_servlet.resources.RAML.java

/**
 * Get the servlet configuration//from  w  w w. j  ava  2 s  .co  m
 * <p>
 * @return HTTP response containing the Servlet configuration in JSON format
 */
@GET
@Path("config")
@Produces(MediaType.APPLICATION_JSON)
public Response getConfig() {

    log.info("GET raml/config");

    Map<String, Object> configMap = new LinkedHashMap<String, Object>();

    try {
        Context initialContext = new InitialContext();
        Context envContext = (Context) initialContext.lookup("java:comp/env");

        configMap.put("vseServerUrl", envContext.lookup("vseServerUrl"));
        configMap.put("vseServicePortRange", envContext.lookup("vseServicePortRange"));
        configMap.put("vseServiceReadyWaitSeconds", envContext.lookup("vseServiceReadyWaitSeconds"));

    } catch (NamingException e) {
        e.printStackTrace();
        log.error("Failed to obtain servlet configuration", e.getCause());
    }

    GsonBuilder gsonBuilder = new GsonBuilder();

    gsonBuilder.setPrettyPrinting();
    gsonBuilder.serializeNulls();

    Gson gson = gsonBuilder.create();

    Response response = Response.status(200).entity(gson.toJson(configMap)).build();

    return response;
}

From source file:org.sha.util.Shaincidencias.java

public void onselectCi() {
    if (ci == null) {
        ci = " - ";
    }//from   ww w  .  j  a v a 2 s .  c  o m

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // CONSULTA QUE HACE LA SELECCION AUTOMATICA PARA LOS INPUTTEXT DE LOS EMPLEADOS, RETORNANDO   //
    // LOS VALORES DE  NOMBRE, GENERO Y CARGO DE CADA UNO QUE NO SEA NOMINA CONFIDENCIAL, A LOS DE //
    // DICHA NOMINA LE RETORNA VALORES PREDEFINIDOS DEBIDO AL ESQUEMA DE ALMACEN DE DATA           //
    // CONFIDENCIAL QUE MANEJA BAAN EN SU BD.                                                      //
    /////////////////////////////////////////////////////////////////////////////////////////////////

    String query = " SELECT TRIM(T$NOM1$O)||' '||TRIM(T$NOM2$O)||' '||TRIM(T$APE1$O)||' '||TRIM(T$APE2$O) AS NOMBRE, 'CONFIDENCIAL' AS SEXO,'0A1 - CONFIDENCIAL' AS CARGO";
    query += " FROM ttfinn911100@baan_oracle A";
    query += " WHERE A.T$TIPO$O = 2";
    query += " AND 'C - '||TRIM(A.T$CEDU$O) LIKE '" + ci.toUpperCase() + "%'";
    query += " GROUP BY T$NOM1$O, T$NOM2$O, T$APE1$O, T$APE2$O";
    query += " UNION ALL";
    query += " SELECT NOMBRE1||' '||NOMBRE2||' '||APELLIDO1||' '||APELLIDO2 AS NOMBRE, SEXO, CODCAR||' - '||DESCAR AS CARGO";
    query += " FROM NM_TRABAJADOR@INFOCENT_CALENDARIO";
    query += " WHERE TIPDOC||' - '||CEDULA like '" + ci.toUpperCase() + "%'";
    query += " AND FECRET IS NULL";
    query += " OR FECRET > SYSDATE";
    query += " GROUP BY NOMBRE1, NOMBRE2, APELLIDO1, APELLIDO2, SEXO, CODCAR, DESCAR";
    query += " ORDER BY NOMBRE";

    PntGenerica select = new PntGenerica();
    try {
        select.selectPntGenerica(query, JNDI);
    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    int rows = select.getRows();
    String vltabla[][] = select.getArray();
    if (rows > 0) {
        zuno = vltabla[0][0];
        zdos = vltabla[0][1];
        ztres = vltabla[0][2];
    }
    //System.out.println(query);
    //System.out.println("zuno:" + zuno);
    //System.out.println("zuno:" + zdos);
    //System.out.println("zuno:" + ztres);
}

From source file:org.jetbrains.webdemo.backend.BackendHttpServlet.java

private boolean loadTomcatParameters() {
    InitialContext initCtx = null;
    try {// w ww. j  a va 2 s.  c  o m
        initCtx = new InitialContext();
        NamingContext envCtx = (NamingContext) initCtx.lookup("java:comp/env");
        try {
            CommandRunner.setServerSettingFromTomcatConfig("java_home", (String) envCtx.lookup("java_home"));
        } catch (NamingException e) {
            CommandRunner.setServerSettingFromTomcatConfig("java_home", System.getenv("JAVA_HOME"));
        }
        try {
            CommandRunner.setServerSettingFromTomcatConfig("java_execute",
                    (String) envCtx.lookup("java_execute"));
        } catch (NamingException e) {
            String executable = isWindows() ? "java.exe" : "java";
            CommandRunner.setServerSettingFromTomcatConfig("java_execute",
                    BackendSettings.JAVA_HOME + File.separator + "bin" + File.separator + executable);
        }
        try {
            CommandRunner.setServerSettingFromTomcatConfig("app_output_dir",
                    (String) envCtx.lookup("app_output_dir"));
        } catch (NamingException e) {
            File rootFolder = new File(BackendSettings.WEBAPP_ROOT_DIRECTORY);
            String appHome = rootFolder.getParentFile().getParentFile().getParent();
            CommandRunner.setServerSettingFromTomcatConfig("app_output_dir", appHome);
        }

        try {
            CommandRunner.setServerSettingFromTomcatConfig("is_test_version",
                    (String) envCtx.lookup("is_test_version"));
        } catch (NameNotFoundException e) {
            //Absent is_test_version variable in context.xml
            CommandRunner.setServerSettingFromTomcatConfig("is_test_version", "false");
        }
        try {
            CommandRunner.setServerSettingFromTomcatConfig("timeout", (String) envCtx.lookup("timeout"));
        } catch (NameNotFoundException e) {
            //Absent timeout variable in context.xml
        }

        return true;
    } catch (Throwable e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        return false;
    }

}

From source file:com.globalsight.everest.usermgr.UserManagerLocal.java

/**
 * Returns an DirContext object to the connection pool.
 *//*from w  ww  .j  a va  2 s.  c o m*/
private void checkInConnection(DirContext dirContext) {

    try {
        dirContextPool.closeDirContext(dirContext);
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

From source file:org.openbizview.util.Programacion.java

/**En caso que se requiera envia correos manualmente al grupo
 * @throws IOException **//*w  w  w.ja va 2s.  co m*/

public void enviarMailmanual() throws IOException {

    java.sql.Date sqlDate = new java.sql.Date(fechadia.getTime());
    //Para reportes
    int rowsrep;
    String[][] vltablarep;

    try {
        String vlqueryRep = "select trim(codrep), trim(rutarep), trim(rutatemp), trim(disparador), trim(formato), to_char(diainicio,'HH24:mi'), case when trim(paramnames) is null then '0' else trim(paramnames) end, case when trim(paramvalues) is null then '0' else trim(paramvalues) end, trim(asunto), trim(contenido), trim(dias_semana)";
        vlqueryRep += " from t_programacion";
        vlqueryRep += " where disparador='" + vltrigger.toUpperCase() + "'";
        //System.out.println(vlqueryRep);   

        consulta.selectPntGenerica(vlqueryRep, JNDI);

        ////System.out.println("select nombrereporte, idgrupo, trim(rutareporte), trim(rutatemp) from mailtarea where hora='" + formato.format(new Date()) + "'");

        rowsrep = consulta.getRows();
        vltablarep = consulta.getArray();

        //Imprime reporte
        if (rowsrep > 0) {//Si la consulta es mayor a cero devuelve registros enva el correo

            new RunReport().outReporteRecibo(vltablarep[0][0].toString(), vltablarep[0][4].toString(),
                    vltablarep[0][1].toString(), vltablarep[0][2].toString(), vltablarep[0][0].toString(),
                    sqlDate, vltablarep[0][3].toString(), vltablarep[0][6].toString(),
                    vltablarep[0][7].toString());

            for (int i = 0; i < rowsrep; i++) {
                new Sendmail().mailthread(vltrigger.toUpperCase(), vltablarep[i][2], vltablarep[i][0],
                        vltablarep[i][8], vltablarep[i][9], vltablarep[i][4]);
            }
        }
        msj = new FacesMessage(FacesMessage.SEVERITY_INFO, getMessage("mailtareaEnvo1"), "");
        FacesContext.getCurrentInstance().addMessage(null, msj);
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

From source file:org.openbizview.util.Programacion.java

/**
* Retorna el nmero de parmetros//from   w w  w .ja  va2 s.c o  m
* <p>
**/
public Integer paramsNumber(String reporte) {
    Integer param = 0;
    int vlrows = 0;
    String vlquery = "select paramnumber from bvtparams_number_temp where sessionid = '" + session + "'";
    try {
        consulta.selectPntGenerica(vlquery, JNDI);
        vlrows = consulta.getRows();
        if (vlrows > 0) {
            String[][] vltabla = consulta.getArray();
            param = Integer.parseInt(vltabla[0][0]);
        }
    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return param;
}