List of usage examples for javax.naming NamingException printStackTrace
public void printStackTrace()
From source file:gov.nih.nci.security.util.ConfigurationHelper.java
private DataSource getDataSourceFromDocument(Document hibernateConfigDoc) throws CSConfigurationException { Element hbnConfigElement = hibernateConfigDoc.getRootElement(); DataSource ds = null;/*from w ww. j ava 2s.c om*/ org.jdom.Element urlProperty = null, usernameProperty = null, passwordProperty = null, driverProperty = null; try { org.jdom.Element dataSourceProperty = (org.jdom.Element) XPath.selectSingleNode(hibernateConfigDoc, "/hibernate-configuration//session-factory//property[@name='connection.datasource']"); if (dataSourceProperty != null && dataSourceProperty.getTextTrim() != null) { try { InitialContext initialContext = new InitialContext(); ds = (DataSource) initialContext.lookup(dataSourceProperty.getTextTrim()); } catch (NamingException ex) { ex.printStackTrace(); throw new CSConfigurationException(); } } else { urlProperty = (org.jdom.Element) XPath.selectSingleNode(hibernateConfigDoc, "/hibernate-configuration//session-factory//property[@name='connection.url']"); usernameProperty = (org.jdom.Element) XPath.selectSingleNode(hibernateConfigDoc, "/hibernate-configuration//session-factory//property[@name='connection.username']"); passwordProperty = (org.jdom.Element) XPath.selectSingleNode(hibernateConfigDoc, "/hibernate-configuration//session-factory//property[@name='connection.password']"); driverProperty = (org.jdom.Element) XPath.selectSingleNode(hibernateConfigDoc, "/hibernate-configuration//session-factory//property[@name='connection.driver_class']"); DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(driverProperty.getTextTrim()); dataSource.setUrl(urlProperty.getTextTrim()); dataSource.setUsername(usernameProperty.getTextTrim()); dataSource.setPassword(passwordProperty.getTextTrim()); ds = dataSource; } } catch (JDOMException e) { e.printStackTrace(); throw new CSConfigurationException(); } return ds; }
From source file:org.openhie.openempi.recordlinkage.protocols.TwoThirdPartySimpleSendProtocol.java
public PersonMatchRequest sendPersonMatchRequest(Dataset dataset, String remoteTableName, String matchName, String keyServerUserName, String keyServerPassword, String dataIntegratorUserName, String dataIntegratorPassword, String parameterManagerUserName, String parameterManagerPassword) { long startTime1 = System.currentTimeMillis(); log.warn("Send preparation Start: " + startTime1); long totalMem = Runtime.getRuntime().totalMemory(); long freeMem = Runtime.getRuntime().freeMemory(); log.warn("Used memory = " + (totalMem - freeMem) + " total (" + totalMem + ") - free (" + freeMem + ")"); PrivacySettings privacySettings = (PrivacySettings) Context.getConfiguration() .lookupConfigurationEntry(ConfigurationRegistry.RECORD_LINKAGE_PROTOCOL_SETTINGS); DataIntegratorSettings dataIntegratorSettings = privacySettings.getComponentSettings() .getDataIntegratorSettings(); String serverAddress4DI = dataIntegratorSettings.getServerAddress(); long startTime2 = 0; try {/* w ww . j a v a2 s .c om*/ RemotePersonService remotePersonService = Context.getRemotePersonService(); remotePersonService.close(); remotePersonService.authenticate(serverAddress4DI, dataIntegratorUserName, dataIntegratorPassword, keyServerUserName, keyServerPassword); long endTime1 = System.currentTimeMillis(); log.warn("Send preparation End: " + endTime1 + ", elapsed: " + (endTime1 - startTime1)); startTime2 = System.currentTimeMillis(); log.warn("Send Start: " + startTime2); totalMem = Runtime.getRuntime().totalMemory(); freeMem = Runtime.getRuntime().freeMemory(); log.warn( "Used memory = " + (totalMem - freeMem) + " total (" + totalMem + ") - free (" + freeMem + ")"); // Send all columns here, it's not PRL // Maybe we could do some intelligent cherry picking analyzing the match configuration? List<ColumnInformation> columnInformation = dataset.getColumnInformation(); remotePersonService.createDatasetTable(remoteTableName, columnInformation, dataset.getTotalRecords(), false); List<String> columnNames = new ArrayList<String>(); for (ColumnInformation ci : columnInformation) { columnNames.add(ci.getFieldName()); } long firstResult = 0L; boolean morePatients = true; List<Person> persons = null; PersonQueryService personQueryService = Context.getPersonQueryService(); do { persons = personQueryService.getPersonsPaged(dataset.getTableName(), columnNames, firstResult, Constants.PAGE_SIZE); morePatients = (persons != null && persons.size() > 0); if (morePatients) { remotePersonService.addPersons(remoteTableName, persons, false, false); } firstResult += persons.size(); } while (morePatients); remotePersonService.addIndexesAndConstraintsToDatasetTable(remoteTableName, firstResult + 1); } catch (NamingException e) { log.error("Couldn't connect to Data Integrator (" + serverAddress4DI + ") to send the dataset"); e.printStackTrace(); } catch (Exception e) { log.error("Error occured during creation, generation or loading of BF or CBF data"); e.printStackTrace(); } long endTime2 = System.currentTimeMillis(); log.warn("Send End: " + endTime2 + ", elapsed: " + (endTime2 - startTime2)); totalMem = Runtime.getRuntime().totalMemory(); freeMem = Runtime.getRuntime().freeMemory(); log.warn("Used memory = " + (totalMem - freeMem) + " total (" + totalMem + ") - free (" + freeMem + ")"); return null; }
From source file:LDAPTest.java
public LDAPFrame() { setTitle("LDAPTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); JPanel northPanel = new JPanel(); northPanel.setLayout(new java.awt.GridLayout(1, 2, 3, 1)); northPanel.add(new JLabel("uid", SwingConstants.RIGHT)); uidField = new JTextField(); northPanel.add(uidField);//from www . j a v a 2 s .c om add(northPanel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(); add(buttonPanel, BorderLayout.SOUTH); findButton = new JButton("Find"); findButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { findEntry(); } }); buttonPanel.add(findButton); saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveEntry(); } }); buttonPanel.add(saveButton); deleteButton = new JButton("Delete"); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { deleteEntry(); } }); buttonPanel.add(deleteButton); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { try { if (context != null) context.close(); } catch (NamingException e) { e.printStackTrace(); } } }); }
From source file:com.reversemind.hypergate.server.PayloadProcessor.java
@Override public Payload process(Object payloadObject) { if (payloadObject == null) { LOG.info("ERROR: " + PayloadStatus.ERROR_CLIENT_PAYLOAD); return PayloadBuilder.buildErrorPayload(PayloadStatus.ERROR_CLIENT_PAYLOAD); }//from w w w . j a v a 2s.co m if (!(payloadObject instanceof Payload)) { LOG.info("ERROR: " + PayloadStatus.ERROR_CLIENT_PAYLOAD); return PayloadBuilder.buildErrorPayload(PayloadStatus.ERROR_CLIENT_PAYLOAD); } Payload payload = ((Payload) payloadObject); LOG.debug("Get from client:" + payload); Class interfaceClass = payload.getInterfaceClass(); Class pojoClass = this.findPOJOClass(interfaceClass); // POJO if (pojoClass != null) { return this.invokeMethod(payload, pojoClass, payload.getMethodName(), payload.getArguments()); } // EJB String jndiName = this.findEjbClass(interfaceClass); if (!StringUtils.isEmpty(jndiName)) { try { // JBoss AS 7 JNDI name // buildingDAO = InitialContext.doLookup("java:global/ttk-house/ttk-house-ejb-2.0-SNAPSHOT/BuildingDAO!ru.ttk.baloo.house.data.service.building.IBuildingDAO"); Object remoteObject = InitialContext.doLookup(jndiName); return this.invokeEjbMethod(payload, remoteObject, payload.getMethodName(), payload.getArguments()); } catch (NamingException e) { e.printStackTrace(); } } return PayloadBuilder.buildErrorPayload(PayloadStatus.ERROR_UNKNOWN); }
From source file:LDAPTest.java
/** * Deletes the entry for the uid in the text field. *///from w w w .j av a 2 s . co m public void deleteEntry() { try { String dn = "uid=" + uidField.getText() + ",ou=people,dc=mycompany,dc=com"; if (context == null) context = getContext(); context.destroySubcontext(dn); uidField.setText(""); remove(scrollPane); scrollPane = null; repaint(); } catch (NamingException e) { JOptionPane.showMessageDialog(LDAPFrame.this, e); e.printStackTrace(); } catch (IOException e) { JOptionPane.showMessageDialog(LDAPFrame.this, e); e.printStackTrace(); } }
From source file:com.nidhinova.tika.server.TikaService.java
/** * Returns a URL for pathkey from JNDI. Used in calls that processes * network-accessible files where you don't want to expose the absolute path * Ensure pathkey is available in JNDI/*from ww w. j a v a 2s .c om*/ * * @return filepath */ private String getFilePath(String pathkey) { logger.info("Getting path for " + pathkey); String path = ""; try { javax.naming.Context initCtx = new InitialContext(); path = (String) initCtx.lookup("java:comp/env/" + pathkey); } catch (NamingException e) { e.printStackTrace(); } return path; }
From source file:br.ufc.ivela.web.action.GenericAction.java
public void addHistory(String title, String description, SystemUser systemUser, String... params) { if (historyRemote == null) { try {//from w w w . j a v a 2 s . c o m InitialContext initialContext = new InitialContext(); java.lang.Object ejbRemoteRef = initialContext .lookup("HistoryBean#br.ufc.ivela.ejb.interfaces.HistoryRemote"); historyRemote = (HistoryRemote) javax.rmi.PortableRemoteObject.narrow(ejbRemoteRef, HistoryRemote.class); } catch (NamingException e) { e.printStackTrace(); historyRemote = null; } } List<History> historyList = historyRemote.getBySystemUser(systemUser.getId()); boolean insert = true; for (History h : historyList) { if (h.getDescription().equalsIgnoreCase(description) && h.getTitle().equalsIgnoreCase(title)) { List<HistoryParams> historyParamsList = historyParamsRemote.getByHistory(h.getId()); int equal = 0; for (int i = 0; i < params.length; i++) { for (HistoryParams hp : historyParamsList) { if (hp.getParam().equalsIgnoreCase(String.valueOf(i)) && hp.getValue().equalsIgnoreCase(params[i])) { equal++; break; } } } if (equal == params.length) { insert = false; break; } } } if (insert) { History history = new History(); history.setSystemUser(systemUser); history.setDatetime(new Date()); history.setTitle(title); history.setDescription(description); Long id = historyRemote.add(history); for (int i = 0; params != null && i < params.length; i++) { HistoryParams historyParams = new HistoryParams(); historyParams.setHistoryId(id); historyParams.setParam(String.valueOf(i)); historyParams.setValue(params[i]); historyParamsRemote.add(historyParams); } } }
From source file:br.ufc.ivela.web.action.GenericAction.java
public void addHistory(String title, String description, String... params) { if (historyRemote == null) { try {/*w w w. j a v a 2s . co m*/ InitialContext initialContext = new InitialContext(); java.lang.Object ejbRemoteRef = initialContext .lookup("HistoryBean#br.ufc.ivela.ejb.interfaces.HistoryRemote"); historyRemote = (HistoryRemote) javax.rmi.PortableRemoteObject.narrow(ejbRemoteRef, HistoryRemote.class); } catch (NamingException e) { e.printStackTrace(); historyRemote = null; } } List<History> historyList = historyRemote.getBySystemUser(getAuthenticatedUser().getId()); boolean insert = true; for (History h : historyList) { if (h.getDescription().equalsIgnoreCase(description) && h.getTitle().equalsIgnoreCase(title)) { List<HistoryParams> historyParamsList = historyParamsRemote.getByHistory(h.getId()); int equal = 0; for (int i = 0; i < params.length; i++) { for (HistoryParams hp : historyParamsList) { if (hp.getParam().equalsIgnoreCase(String.valueOf(i)) && hp.getValue().equalsIgnoreCase(params[i])) { equal++; break; } } } if (equal == params.length) { insert = false; break; } } } if (insert) { History history = new History(); history.setSystemUser(getAuthenticatedUser()); history.setDatetime(new Date()); history.setTitle(title); history.setDescription(description); Long id = historyRemote.add(history); for (int i = 0; params != null && i < params.length; i++) { HistoryParams historyParams = new HistoryParams(); historyParams.setHistoryId(id); historyParams.setParam(String.valueOf(i)); historyParams.setValue(params[i]); historyParamsRemote.add(historyParams); } } }
From source file:LDAPTest.java
/** * Saves the changes that the user made. */// w ww. jav a 2 s . co m public void saveEntry() { try { if (dataPanel == null) return; if (context == null) context = getContext(); if (uidField.getText().equals(uid)) // update existing entry { String dn = "uid=" + uidField.getText() + ",ou=people,dc=mycompany,dc=com"; Attributes editedAttrs = dataPanel.getEditedAttributes(); NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll(); while (attrEnum.hasMore()) { Attribute attr = attrEnum.next(); String id = attr.getID(); Attribute editedAttr = editedAttrs.get(id); if (editedAttr != null && !attr.get().equals(editedAttr.get())) context.modifyAttributes(dn, DirContext.REPLACE_ATTRIBUTE, new BasicAttributes(id, editedAttr.get())); } } else // create new entry { String dn = "uid=" + uidField.getText() + ",ou=people,dc=mycompany,dc=com"; attrs = dataPanel.getEditedAttributes(); Attribute objclass = new BasicAttribute("objectClass"); objclass.add("uidObject"); objclass.add("person"); attrs.put(objclass); attrs.put("uid", uidField.getText()); context.createSubcontext(dn, attrs); } findEntry(); } catch (NamingException e) { JOptionPane.showMessageDialog(LDAPFrame.this, e); e.printStackTrace(); } catch (IOException e) { JOptionPane.showMessageDialog(LDAPFrame.this, e); e.printStackTrace(); } }
From source file:eu.uqasar.web.dashboard.widget.datadeviation.DataDeviationSettingsPanel.java
public DataDeviationSettingsPanel(String id, IModel<DataDeviationWidget> model) { super(id, model); setOutputMarkupPlaceholderTag(true); // Get the project from the settings projectName = getModelObject().getSettings().get("project"); // DropDown select for Projects TreeNodeService treeNodeService = null; try {/*from w ww .j a va 2 s .co m*/ 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(); } //Form and WMCs final Form<Widget> form = new Form<>("form"); wmcGeneral = newWebMarkupContainer("wmcGeneral"); form.add(wmcGeneral); //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); int noOfObjs = OBJS.size(); int noOfIndis = INDIS.size(); if (index + 1 == 1 && noOfObjs > 0) { buffer.append("<optgroup label='Quality Objectives'></optgroup>"); } 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); 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); DataDeviationWidgetView widgetView = (DataDeviationWidgetView) widgetPanel.getWidgetView(); target.add(widgetView); 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); }