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:eu.uqasar.web.dashboard.widget.uqasardatavisualization.UqasarDataVisualizationSettingsPanel.java

public UqasarDataVisualizationSettingsPanel(String id, IModel<UqasarDataVisualizationWidget> model) {
    super(id, model);

    setOutputMarkupPlaceholderTag(true);

    //Form and WMCs
    final Form<Widget> form = new Form<>("form");
    wmcGeneral = newWebMarkupContainer("wmcGeneral");
    form.add(wmcGeneral);/*from www  .jav  a  2 s .  c o m*/

    // Get the project from the settings
    projectName = getModelObject().getSettings().get("project");

    // DropDown select for Projects
    TreeNodeService treeNodeService = null;
    try {
        InitialContext ic = new InitialContext();
        treeNodeService = (TreeNodeService) ic.lookup("java:module/TreeNodeService");
        projects = treeNodeService.getAllProjectsOfLoggedInUser();
        if (projects != null && projects.size() != 0) {
            if (projectName == null || projectName.isEmpty()) {
                projectName = projects.get(0).getName();
            }
            project = treeNodeService.getProjectByName(projectName);
            recreateAllProjectTreeChildrenForProject(project);
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }
    //project
    List<String> joinedQualityParameters = ListUtils.union(ListUtils.union(OBJS, INDIS), MTRX);
    qualityParameterChoice = new DropDownChoice<String>("qualityParams",
            new PropertyModel<String>(this, "qualityParams"), joinedQualityParameters) {
        @Override
        protected void appendOptionHtml(AppendingStringBuffer buffer, String choice, int index,
                String selected) {
            super.appendOptionHtml(buffer, choice, index, selected);

            if (UqasarDataVisualizationWidget.ALL.get(0).equals(choice)) {
                buffer.append("<optgroup label='Quality Objectives'></optgroup>");
            }

            int noOfObjs = OBJS.size();
            int noOfIndis = INDIS.size();

            if (index + 1 == noOfObjs && noOfObjs > 0) {
                buffer.append("<optgroup label='Quality Indicators'></optgroup>");
            }
            if (index + 1 == (noOfObjs + noOfIndis) && noOfIndis > 0) {
                buffer.append("<optgroup label='Metrics'></optgroup>");
            }

        }
    };
    qualityParameterChoice.setOutputMarkupId(true);
    wmcGeneral.add(qualityParameterChoice);

    // project
    projectChoice = new DropDownChoice<>("projects", new PropertyModel<Project>(this, "project"), projects);
    if (project != null) {
        projectChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                System.out.println(project);
                recreateAllProjectTreeChildrenForProject(project);
                qualityParameterChoice.setChoices(ListUtils.union(ListUtils.union(OBJS, INDIS), MTRX));
                target.add(qualityParameterChoice);
                target.add(wmcGeneral);

                target.add(form);
            }
        });

    }

    wmcGeneral.setOutputMarkupId(true);
    wmcGeneral.add(projectChoice);

    form.add(new AjaxSubmitLink("submit") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            if (project != null) {
                getModelObject().getSettings().put("qualityParams", qualityParams);
                getModelObject().getSettings().put("project", project.getName());

                Dashboard dashboard = findParent(DashboardPanel.class).getDashboard();
                DbDashboard dbdb = (DbDashboard) dashboard;

                WidgetPanel widgetPanel = findParent(WidgetPanel.class);
                UqasarDataVisualizationWidgetView widgetView = (UqasarDataVisualizationWidgetView) widgetPanel
                        .getWidgetView();
                target.add(widgetPanel);
                hideSettingPanel(target);

                // Do not save the default dashboard
                if (dbdb.getId() != null && dbdb.getId() != 0) {
                    dashboardContext.getDashboardPersiter().save(dashboard);
                    PageParameters params = new PageParameters();
                    params.add("id", dbdb.getId());
                    setResponsePage(DashboardViewPage.class, params);
                }
            }
        }
    });
    form.add(new AjaxLink<Void>("cancel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            hideSettingPanel(target);
        }
    });

    add(form);
}

From source file:org.jengine.mbean.FTPHL7Client.java

private void initializeQueueConnection() {
    try {//from w ww.  j av a  2s.  c  o  m
        if (session != null)
            session.close();
        ctx = getInitialContext();
        factory = (QueueConnectionFactory) ctx.lookup(CONNECTION_FACTORY);
        connection = factory.createQueueConnection();
        session = connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);

        StringTokenizer st = new StringTokenizer(QueueNames, ":");
        while (st.hasMoreElements()) {
            queue = (Queue) ctx.lookup("queue/" + st.nextElement());
            Queues.add(queue);
            qSender = session.createSender(queue);
            QSenders.add(qSender);
        }
    } catch (JMSException je) {
        je.printStackTrace();

    } catch (NamingException ne) {
        ne.printStackTrace();

    }

}

From source file:com.heliumv.api.order.OrderApi.java

@GET
@Produces({ FORMAT_JSON, FORMAT_XML })//from   w ww.  j  a  v  a2s .  com
public List<OrderEntry> getOrders(@QueryParam(Param.USERID) String userId,
        @QueryParam(Param.LIMIT) Integer limit, @QueryParam(Param.STARTINDEX) Integer startIndex,
        @QueryParam("filter_cnr") String filterCnr, @QueryParam("filter_customer") String filterCustomer,
        @QueryParam("filter_project") String filterProject,
        @QueryParam("filter_withHidden") Boolean filterWithHidden) {
    List<OrderEntry> orders = new ArrayList<OrderEntry>();

    try {
        if (null == connectClient(userId))
            return orders;
        if (!mandantCall.hasModulAuftrag()) {
            respondNotFound();
            return orders;
        }

        FilterKriteriumCollector collector = new FilterKriteriumCollector();
        collector.add(orderQuery.getFilterCnr(StringHelper.removeXssDelimiters(filterCnr)));
        collector.add(orderQuery.getFilterProject(StringHelper.removeXssDelimiters(filterProject)));
        collector.add(orderQuery.getFilterCustomer(StringHelper.removeXssDelimiters(filterCustomer)));
        collector.add(orderQuery.getFilterWithHidden(filterWithHidden));
        FilterBlock filterCrits = new FilterBlock(collector.asArray(), "AND");

        QueryParameters params = orderQuery.getDefaultQueryParameters(filterCrits);
        params.setLimit(limit);
        params.setKeyOfSelectedRow(startIndex);

        QueryResult result = orderQuery.setQuery(params);
        orders = orderQuery.getResultList(result);
    } catch (NamingException e) {
        respondUnavailable(e);
        e.printStackTrace();
    } catch (RemoteException e) {
        respondUnavailable(e);
        e.printStackTrace();
    }

    return orders;
}

From source file:com.heliumv.api.order.OrderApi.java

@GET
@Path("position")
@Produces({ FORMAT_JSON, FORMAT_XML })//w w w .  j av a  2s .  co m
public List<OrderpositionsEntry> getOrderPositions(@QueryParam(Param.USERID) String userId,
        @QueryParam(Param.LIMIT) Integer limit, @QueryParam(Param.STARTINDEX) Integer startIndex,
        @QueryParam("filter_cnr") String filterCnr, @QueryParam("filter_customer") String filterCustomer,
        @QueryParam("filter_project") String filterProject,
        @QueryParam("filter_withHidden") Boolean filterWithHidden) {
    List<OrderpositionsEntry> entries = new ArrayList<OrderpositionsEntry>();

    try {
        if (null == connectClient(userId))
            return entries;
        if (!mandantCall.hasModulAuftrag()) {
            respondNotFound();
            return entries;
        }

        FilterKriteriumCollector collector = new FilterKriteriumCollector();
        collector.add(orderQuery.getFilterCnr(StringHelper.removeXssDelimiters(filterCnr)));
        collector.add(orderQuery.getFilterProject(StringHelper.removeXssDelimiters(filterProject)));
        collector.add(orderQuery.getFilterCustomer(StringHelper.removeXssDelimiters(filterCustomer)));
        collector.add(orderQuery.getFilterWithHidden(filterWithHidden));
        FilterBlock filterCrits = new FilterBlock(collector.asArray(), "AND");

        QueryParameters params = orderQuery.getDefaultQueryParameters(filterCrits);
        params.setLimit(limit);
        params.setKeyOfSelectedRow(startIndex);

        QueryResult result = orderQuery.setQuery(params);
        List<OrderEntry> orders = orderQuery.getResultList(result);

        for (OrderEntry orderEntry : orders) {
            collector = new FilterKriteriumCollector();
            collector.add(orderPositionQuery.getOrderIdFilter(orderEntry.getId()));

            filterCrits = new FilterBlock(collector.asArray(), "AND");

            params = orderPositionQuery.getDefaultQueryParameters(filterCrits);
            params.setLimit(Integer.MAX_VALUE);
            params.setKeyOfSelectedRow(0);

            QueryResult positionResult = orderPositionQuery.setQuery(params);
            List<OrderpositionEntry> posEntries = orderPositionQuery.getResultList(positionResult);

            addPositionEntries(entries, orderEntry.getId(), posEntries);
        }
    } catch (NamingException e) {
        respondUnavailable(e);
        e.printStackTrace();
    } catch (RemoteException e) {
        respondUnavailable(e);
        e.printStackTrace();
    }

    return entries;
}

From source file:at.alladin.rmbt.statisticServer.StatisticsResource.java

private String generateStatistics(final StatisticParameters params, final String cacheKey) {
    String result;/*  ww w  .  ja  v  a2 s  . c  om*/
    final String lang = params.getLang();
    final float quantile = params.getQuantile();
    final int durationDays = params.getDuration();
    final int maxDevices = params.getMaxDevices();
    final String type = params.getType();
    final String networkTypeGroup = params.getNetworkTypeGroup();
    final double accuracy = params.getAccuracy();
    final String country = params.getCountry();

    boolean useMobileProvider = false;

    final boolean signalMobile;
    final String where;
    if (type.equals("mobile")) {
        signalMobile = true;
        useMobileProvider = true;

        if (networkTypeGroup == null)
            where = "nt.type = 'MOBILE'";
        else {
            if ("2G".equalsIgnoreCase(networkTypeGroup))
                where = "nt.group_name = '2G'";
            else if ("3G".equalsIgnoreCase(networkTypeGroup))
                where = "nt.group_name = '3G'";
            else if ("4G".equalsIgnoreCase(networkTypeGroup))
                where = "nt.group_name = '4G'";
            else if ("mixed".equalsIgnoreCase(networkTypeGroup))
                where = "nt.group_name IN ('2G/3G','2G/4G','3G/4G','2G/3G/4G')";
            else
                where = "1=0";
        }
    } else if (type.equals("wifi")) {
        where = "nt.type='WLAN'";
        signalMobile = false;
    } else if (type.equals("browser")) {
        where = "nt.type = 'LAN'";
        signalMobile = false;
    } else { // invalid request
        where = "1=0";
        signalMobile = false;
    }

    final JSONObject answer = new JSONObject();

    try (Connection conn = DbConnection.getConnection()) {
        final JSONArray providers = new JSONArray();
        answer.put("providers", providers);
        final JSONArray devices = new JSONArray();
        answer.put("devices", devices);
        answer.put("quantile", quantile);
        answer.put("duration", durationDays);
        answer.put("type", type);

        try (PreparedStatement ps = selectProviders(conn, true, quantile, durationDays, accuracy, country,
                useMobileProvider, where, signalMobile); ResultSet rs = ps.executeQuery()) {
            fillJSON(lang, rs, providers);
        }

        try (PreparedStatement ps = selectProviders(conn, false, quantile, durationDays, accuracy, country,
                useMobileProvider, where, signalMobile); ResultSet rs = ps.executeQuery()) {
            final JSONArray providersSumsArray = new JSONArray();
            fillJSON(lang, rs, providersSumsArray);
            if (providersSumsArray.length() == 1)
                answer.put("providers_sums", providersSumsArray.get(0));
        }

        try (PreparedStatement ps = selectDevices(conn, true, quantile, durationDays, accuracy, country,
                useMobileProvider, where, maxDevices); ResultSet rs = ps.executeQuery()) {
            fillJSON(lang, rs, devices);
        }

        try (PreparedStatement ps = selectDevices(conn, false, quantile, durationDays, accuracy, country,
                useMobileProvider, where, maxDevices); ResultSet rs = ps.executeQuery()) {
            final JSONArray devicesSumsArray = new JSONArray();
            fillJSON(lang, rs, devicesSumsArray);
            if (devicesSumsArray.length() == 1)
                answer.put("devices_sums", devicesSumsArray.get(0));
        }

        final JSONArray countries = new JSONArray(getCountries(conn));
        answer.put("countries", countries);

        result = answer.toString();
        return result;
    } catch (final JSONException e) {
        e.printStackTrace();
    } catch (final SQLException e) {
        e.printStackTrace();
    } catch (final NamingException e1) {
        e1.printStackTrace();
    }
    return null;
}

From source file:es.udl.asic.user.OpenLdapDirectoryProvider.java

public boolean authenticateUser(String userLogin, UserEdit edit, String password) {
    Hashtable env = new Hashtable();
    InitialDirContext ctx;//  w w  w.j a va2  s.c  o  m

    String INIT_CTX = "com.sun.jndi.ldap.LdapCtxFactory";
    String MY_HOST = getLdapHost() + ":" + getLdapPort();
    String cn;
    boolean returnVal = false;

    if (!password.equals("")) {

        env.put(Context.INITIAL_CONTEXT_FACTORY, INIT_CTX);
        env.put(Context.PROVIDER_URL, MY_HOST);
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_CREDENTIALS, "secret");

        String[] returnAttribute = { "ou" };
        SearchControls srchControls = new SearchControls();
        srchControls.setReturningAttributes(returnAttribute);
        srchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);

        String searchFilter = "(&(objectclass=person)(uid=" + escapeSearchFilterTerm(userLogin) + "))";

        try {
            ctx = new InitialDirContext(env);
            NamingEnumeration answer = ctx.search(getBasePath(), searchFilter, srchControls);
            String trobat = "false";

            while (answer.hasMore() && trobat.equals("false")) {

                SearchResult sr = (SearchResult) answer.next();
                String dn = sr.getName().toString() + "," + getBasePath();

                // Second binding
                Hashtable authEnv = new Hashtable();
                try {
                    authEnv.put(Context.INITIAL_CONTEXT_FACTORY, INIT_CTX);
                    authEnv.put(Context.PROVIDER_URL, MY_HOST);
                    authEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
                    authEnv.put(Context.SECURITY_PRINCIPAL, sr.getName() + "," + getBasePath());
                    authEnv.put(Context.SECURITY_CREDENTIALS, password);
                    try {
                        DirContext authContext = new InitialDirContext(authEnv);
                        returnVal = true;
                        trobat = "true";
                        authContext.close();
                    } catch (AuthenticationException ae) {
                        M_log.info("Access forbidden");
                    }

                } catch (NamingException namEx) {
                    M_log.info("User doesn't exist");
                    returnVal = false;
                    namEx.printStackTrace();
                }
            }
            if (trobat.equals("false"))
                returnVal = false;

        } catch (NamingException namEx) {
            namEx.printStackTrace();
            returnVal = false;
        }
    }
    return returnVal;
}

From source file:org.openbmp.db_rest.resources.Orr.java

/**
 * Initialize the class Sets the data source
 * //from w  ww .j a va2s . com
 * @throws
 */
@PostConstruct
public void init() {
    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:CreateJavaSchema.java

protected void run(String[] args, String[] attrIDs, String[] ocIDs) {
    int cmd = processCommandLine(args);
    try {//from w  ww.  j av a 2s  .co  m
        DirContext ctx = signOn();
        switch (cmd) {
        case UPDATE:
            updateSchema(ctx, attrIDs, ocIDs);
            break;
        default:
            showSchema(ctx, attrIDs, ocIDs);
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

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

public void onselectSuc() {

    if (sucursal == null) {
        sucursal = " - ";
    }//  w  ww.j  a  v  a2s .  c  om

    String[] vecsuc = sucursal.split("\\ - ", -1);

    HttpServletRequest rq = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
            .getRequest();
    String ntrabajador = rq.getParameter("formshametas:numtrabajadores");
    //Consulta que hace la seleccion automatica para los inputtext de los empelados, valores nombre completo, genero, cargo!!!

    //System.out.println("numtrabajadores: " + ntrabajador);

    //System.out.println("anio: " + anio);
    //System.out.println("mes: " + mes);
    String query = " SELECT COUNT(A.FICTRA) AS HEADCOUNT, CASE WHEN COUNT(A.FICTRA) = 0 THEN 0 WHEN COUNT(A.FICTRA) IS NULL THEN 0 ELSE TRUNC("
            + ntrabajador + "/COUNT(A.FICTRA),2) END AS PROMEDIO";
    query += " FROM NM_TRABAJADOR@INFOCENT_CALENDARIO A, SHASUCURSAL B ";
    query += " WHERE A.CODSUC = B.SUCURSAL";
    query += " AND B.CODSUC like '" + vecsuc[0].toUpperCase() + "%'";
    query += " AND A.FECRET IS NULL ";
    query += " ORDER BY 1";

    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:com.wfp.utils.LDAPUtils.java

public static Map<String, String> parseAsMap(NamingEnumeration searchResults, String keyAttribute,
        String valueAttribute) {//  ww w .  j  a va  2  s .c o m
    Logger.debug("# START parseAsMap : Formatting the data as MAP", LDAPUtils.class);
    //System.out.println("# START parseAsMap : Formatting the data as MAP: "+searchResults );
    Map<String, String> resultMap = new HashMap<String, String>();
    if (searchResults == null) {
        return null;
    }
    // Loop through the search results
    while (searchResults.hasMoreElements()) {
        SearchResult sr = null;
        List<String> strList = new ArrayList<String>();
        try {
            sr = (SearchResult) searchResults.next();

        } catch (NamingException e1) {
            Logger.error("No Search results on LDAP ", LDAPUtils.class);
        }
        if (sr == null) {
            Logger.error("No Search results on LDAP ", LDAPUtils.class);
            return null;
        }
        Attributes attrs = sr.getAttributes();
        if (attrs != null) {
            try {
                for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();) {
                    Attribute attr = (Attribute) ae.next();

                    for (NamingEnumeration e = attr.getAll(); e.hasMore(); e.next())
                        ;

                    //System.out.println(" attrs : "+attrs.get(keyAttribute) + ": "+ attrs.get(valueAttribute));
                    //if(attrs.get(keyAttribute)!=null && attrs.get(keyAttribute)!=null)
                    resultMap.put(attrs.get(keyAttribute).toString(), attrs.get(valueAttribute).toString());
                }
            } catch (NamingException ne) {
                ne.printStackTrace();
            }

        } else {
            Logger.info("No attributes found on LDAP", LDAPUtils.class);
        }
    }
    //Logger.debug("# END parseAsMap : Formatting the data as MAP", LDAPUtils.class );
    return resultMap;
}