List of usage examples for javax.naming NamingException printStackTrace
public void printStackTrace()
From source file:fr.cnes.sitools.datasource.jdbc.business.SitoolsDataSourceFactory.java
/** * Retrieval of a DataSource as a JNDI resource * /*from w ww . ja v a2s .c om*/ * Lookup the DataSource, which will be backed by a pool that the application server provides. DataSource instances * are also a good candidate for caching as an instance variable, as JNDI lookups can be expensive as well. * * @param dsName * JNDI resource name * @return DataSource */ public static DataSource getJNDIDataSource(String dsName) { SitoolsDataSource foundDataSource = dataSources.get(dsName); if (foundDataSource != null) { return foundDataSource; } DataSource ds = null; try { InitialContext ctx = new InitialContext(); ds = (DataSource) ctx.lookup(dsName); JDBCDataSource jdbcDS = new JDBCDataSource(); jdbcDS.setName(dsName); dataSources.put(dsName, new SitoolsDataSource(jdbcDS, ds, null)); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ds; }
From source file:dsd.dao.DAOProvider.java
/** * //from w w w. j av a2 s.co m * @return */ public static DataSource getDataSource() { try { if (dataSource == null) { Context ctx = new InitialContext(); dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/RTBMconnection"); } } catch (NamingException e) { e.printStackTrace(); } return dataSource; }
From source file:Main.java
private Connection getConnection() { Connection connection = null; try {//from www.j av a 2 s . c o m InitialContext context = new InitialContext(); DataSource dataSource = (DataSource) context.lookup("jdbc/DataSource"); connection = dataSource.getConnection(); } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return connection; }
From source file:app.cts.form.study.StudyDialogInitialPopulateListener.java
public void populateInitialDialogValues(DialogContext dc, int formatType) { if (dc.editingData() || dc.deletingData()) { String idParam = dc.getHttpRequest().getParameter("study_id"); if (idParam == null || idParam.length() == 0) throw new RuntimeException("Study ID was not found in the request object."); Query query = dc.getSqlManager().getQuery(auto.id.sql.query.Study.GET_STUDY_INFO_BY_ID); try {/*from w w w. jav a 2s . c om*/ QueryResultSet qrs = query.execute(dc, new Object[] { idParam }, false); DialogContextUtils.getInstance().populateFieldValuesFromResultSet(dc, qrs); qrs.close(true); qrs = null; } catch (NamingException e) { e.printStackTrace(); log.error("Failed to populate dialog", e); } catch (SQLException e) { e.printStackTrace(); log.error("Failed to populate dialog", e); } } }
From source file:no.smint.anthropos.authentication.TokenAuthenticationProvider.java
private Person getLoggedInUser(String username) { System.out.println(username); Person person = new Person(); try {/* w ww . j a v a2 s. c o m*/ person = search(username).get(0); } catch (NamingException e) { e.printStackTrace(); } if (person == null) { throw new RestException("User was logged in, but not found in our database!", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } return person; }
From source file:org.openhie.openempi.service.impl.KeyServerServiceImpl.java
public void authenticate(String username, String password) { KeyServiceLocator keyServiceLocator = Context.getKeyServiceLocator(); SecurityService securityService;// w ww. ja v a 2s. co m try { securityService = keyServiceLocator.getSecurityService(); sessionKey = securityService.authenticate(username, password); isAuthenticated = true; } catch (NamingException e) { e.printStackTrace(); log.error(e.getMessage()); } }
From source file:org.openhie.openempi.service.impl.KeyServerServiceImpl.java
public List<byte[]> getKeys(long keyId) { // TODO: if (!isAuthenticated) KeyServiceLocator keyServiceLocator = Context.getKeyServiceLocator(); List<byte[]> keyParts = null; try {//w ww . j a v a 2 s . co m KeyManagerService keyManagerService = keyServiceLocator.getKeyManagerService(); Key key = keyManagerService.getKey(sessionKey, keyId); keyParts = new ArrayList<byte[]>(); byte[] publicKeyPart1 = key.getPublicKeyPart1().clone(); keyParts.add(publicKeyPart1); byte[] publicKeyPart2 = key.getPublicKeyPart2().clone(); keyParts.add(publicKeyPart2); byte[] publicKeyPart3 = key.getPublicKeyPart3().clone(); keyParts.add(publicKeyPart3); byte[] privateKeyPart1 = key.getPrivateKeyPart1().clone(); keyParts.add(privateKeyPart1); byte[] privateKeyPart2 = key.getPrivateKeyPart2().clone(); keyParts.add(privateKeyPart2); byte[] privateKeyPart3 = key.getPrivateKeyPart3().clone(); keyParts.add(privateKeyPart3); } catch (NamingException e) { e.printStackTrace(); log.error(e.getMessage()); } catch (ApplicationException e) { e.printStackTrace(); log.error(e.getMessage()); } return keyParts; }
From source file:com.baidu.stqa.signet.web.action.RoleAction.java
/** * /*from w w w .j av a2 s.c o m*/ * * @param projectId * @param role * @return */ @RequestMapping(value = "/project/{projectId}/role", method = RequestMethod.POST) @ResponseBody public ResponseEntity<Map<String, Object>> addRole(@PathVariable Long projectId, @RequestBody Role role) { doLog(projectId); Boolean result = false; String tag = new Long(new Date().getTime()).toString(); try { result = roleService.generateRole(role.getName(), tag, projectId, role.getRoleSignType()); } catch (NamingException e) { e.printStackTrace(); } Map<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("result", result); resultMap.put("tag", result); return new ResponseEntity<Map<String, Object>>(resultMap, HttpStatus.OK); }
From source file:org.openhie.openempi.service.impl.KeyServerServiceImpl.java
public List<byte[]> getSalts(int numberOfSalts) { // TODO: if (!isAuthenticated) synchronized (salts) { if (salts == null || salts.size() <= 0) { PrivacySettings privacySettings = (PrivacySettings) Context.getConfiguration() .lookupConfigurationEntry(ConfigurationRegistry.RECORD_LINKAGE_PROTOCOL_SETTINGS); KeyServerSettings keyServerSettings = privacySettings.getComponentSettings().getKeyServerSettings(); KeyServiceLocator keyServiceLocator = Context.getKeyServiceLocator(); try { if (salts == null) salts = new ArrayList<byte[]>(); SaltManagerService saltManagerService = keyServiceLocator.getSaltManagerService(); List<Salt> slts = saltManagerService.getSalts(sessionKey, keyServerSettings.getSaltIdStart(), keyServerSettings.getSaltIdStart() + keyServerSettings.getNumberOfSalts() - 1); for (Salt s : slts) { salts.add(s.getSalt()); }/*from ww w . j a v a 2 s .co m*/ } catch (NamingException e) { e.printStackTrace(); log.error(e.getMessage()); } catch (ApplicationException e) { e.printStackTrace(); log.error(e.getMessage()); } } } return salts.subList(0, numberOfSalts); }
From source file:org.ow2.proactive.addons.ldap_query.LDAPClientTest.java
@Test public void testOkResultSearchQueryLDAP() throws NamingException, IOException { PowerMockito.mockStatic(LDAPConnectionUtility.class); try {//from w w w . j a va2s. c o m when(LDAPConnectionUtility.connect(ldapUrl, ldapDnBase, ldapUsername, ldapPassword)) .thenReturn(ldapConnection); } catch (NamingException e) { e.printStackTrace(); } ldapClient = getLdapClient(); NamingEnumeration results = mock(NamingEnumeration.class); when(ldapConnection.search(anyString(), anyString(), any(SearchControls.class))).thenReturn(results); when(results.hasMore()).thenReturn(false); String jsonResponse = ldapClient.searchQueryLDAP(); PowerMockito.verifyStatic(Mockito.times(1)); Response response = mapper.readValue(jsonResponse, LDAPResponse.class); assertThat(response.getStatus(), is("Ok")); }