List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:com.acdd.homelauncher.MainActivity.java
String getCoreVersion() { try {//from ww w . ja v a2 s .c o m Class sdk = Class.forName("org.acdd.sdk.BuildConfig"); Field mField = Reflect.getField(sdk, "ACDDCoreVersion"); String verName = (String) mField.get(null); return verName; } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return "not found"; }
From source file:org.urbantower.j4s.spring.ServletContextHandlerParser.java
/** * method parse 'servlet' and register it into handler *///w w w.j a v a2s .c om private void registerServlet(Element servletElm, ServletHandler handler) { try { //get servlet String servletClassName = servletElm.getAttribute("class"); Class<? extends Servlet> servlerClass = (Class<? extends Servlet>) getClass().getClassLoader() .loadClass(servletClassName); //get name String servletName = getServletName(servletElm, servlerClass); //register servlet handler.addServlet(new ServletHolder(servletName, servlerClass)); //register mappings ServletMapping mapping = createMapping(servletElm, handler, servletName); handler.addServletMapping(mapping); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
From source file:com.softberries.klerk.dao.ProductDao.java
public Product find(Long id, QueryRunner run1, Connection conn1) throws SQLException { Product p = null;// www . j a v a2s . c o m try { init(); ResultSetHandler<Product> h = new BeanHandler<Product>(Product.class); p = run1.query(conn1, SQL_FIND_PRODUCT_BY_ID, h, id); } catch (ClassNotFoundException e) { e.printStackTrace(); } return p; }
From source file:com.softberries.klerk.dao.ProductDao.java
@Override public List<Product> findAll() throws SQLException { List<Product> products = new ArrayList<Product>(); try {/*w w w .ja va 2s . co m*/ init(); ResultSetHandler<List<Product>> h = new BeanListHandler<Product>(Product.class); products = run.query(conn, SQL_FIND_PRODUCT_ALL, h); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { close(conn, st, generatedKeys); } return products; }
From source file:com.softberries.klerk.dao.ProductDao.java
@Override public Product find(Long id) throws SQLException { Product p = null;//ww w. j av a2 s . co m try { init(); ResultSetHandler<Product> h = new BeanHandler<Product>(Product.class); p = run.query(conn, SQL_FIND_PRODUCT_BY_ID, h, id); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { close(conn, st, generatedKeys); } return p; }
From source file:com.square.client.gwt.server.service.UtilServiceGwtImpl.java
@Override @SuppressWarnings("unchecked") public Map<String, String> mapperCriteresRecherche( RemotePagingCriteriasGwt<? extends IsSerializable> criteres) { // on construit l'objet noyau suivant la correspondance try {/*w w w . ja v a 2 s . c om*/ final Class cls = Class.forName(CORRESPONDANCE_TYPE.get(criteres.getCriterias().getClass().getName())); final Constructor ct = cls.getConstructor(); final Object criteriasDto = ct.newInstance(); // on convertit les criteres en criteres noyau mapperDozerBean.map(criteres.getCriterias(), criteriasDto); final RemotePagingCriteriasDto criteresDto = new RemotePagingCriteriasDto(criteriasDto, criteres.getFirstResult(), criteres.getMaxResult()); final List<RemotePagingSort> listSort = mapperDozerBean.mapList(criteres.getListeSorts(), RemotePagingSort.class); criteresDto.setListeSorts(listSort); resetConverter(); final Map<String, String> map = BeanUtils.describe(criteresDto.getCriterias()); map.putAll(BeanUtils.describe(criteresDto)); // on nettoie la map final Set<String> keyset = new HashSet<String>(map.keySet()); for (String key : keyset) { if (StringUtils.isBlank(map.get(key)) || key.equals("class") || key.equals("criterias")) { map.remove(key); } } return map; } catch (ClassNotFoundException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } catch (SecurityException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } catch (NoSuchMethodException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } catch (IllegalArgumentException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } catch (InstantiationException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } catch (IllegalAccessException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } catch (InvocationTargetException e) { e.printStackTrace(); throw new TechnicalException(MESSAGE_ERREUR); } }
From source file:org.geppetto.persistence.db.OSGiLocalPersistenceManagerFactoryBean.java
private ClassLoader getClassLoader() { ClassLoader classloader = null; Bundle[] bundles = bundleContext.getBundles(); for (int x = 0; x < bundles.length; x++) { // if ("org.datanucleus.store.rdbms".equals(bundles[x].getSymbolicName())) { if ("org.datanucleus.api.jdo".equals(bundles[x].getSymbolicName())) { try { classloader = bundles[x].loadClass("org.datanucleus.api.jdo.JDOPersistenceManagerFactory") .getClassLoader(); // classloader = bundles[x].loadClass("org.datanucleus.JDOClassLoaderResolver").getClassLoader(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace();//from w ww . j a v a 2 s. co m } break; } } return classloader; }
From source file:gov.nih.nci.system.web.struts.action.DeleteAction.java
public String execute() throws Exception { init();/* w ww. j a v a2 s . com*/ HttpServletRequest request = ServletActionContext.getRequest(); String targetClass = request.getParameter("target"); if (targetClass == null || targetClass.trim().length() == 0) { request.setAttribute("Message", "Invalid target"); return null; } String idCol = null; try { idCol = classCache.getClassIdName(Class.forName(targetClass)); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (idCol == null) { request.setAttribute("Message", "Invalid target"); return null; } String idColValue = request.getParameter(idCol); if (idColValue == null || idColValue.trim().length() == 0) { request.setAttribute("Message", "Invalid target identifier"); return null; } String confirm = request.getParameter("confirm"); if (confirm == null || confirm.trim().length() == 0 || !confirm.equals("true")) return SUCCESS; String url = request.getRequestURL().toString(); String restURL = url.substring(0, url.lastIndexOf("/")); WebClient client = WebClient.create(restURL); client.path("rest/" + targetClass.substring(targetClass.lastIndexOf(".") + 1, targetClass.length()) + "/" + idColValue); client.type("application/xml").accept("application/xml"); SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION.toString()); org.acegisecurity.context.SecurityContext context = (org.acegisecurity.context.SecurityContext) session .get("ACEGI_SECURITY_CONTEXT"); if (context != null) { Authentication authentication = context.getAuthentication(); // authentication.getCredentials(); String userName = ((org.acegisecurity.userdetails.User) authentication.getPrincipal()).getUsername(); String password = authentication.getCredentials().toString(); String base64encodedUsernameAndPassword = new String( Base64.encodeBase64((userName + ":" + password).getBytes())); client.header("Authorization", "Basic " + base64encodedUsernameAndPassword); } else { if (secured) { request.setAttribute("message", "Invalid authentication"); return SUCCESS; } } Response r = client.delete(); if (r.getStatus() == Status.OK.getStatusCode()) { request.removeAttribute("confirm"); request.setAttribute("successful", "1"); // request.removeAttribute("confirm"); InputStream is = (InputStream) r.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); Element root = jDoc.getRootElement(); Element messageEle = root.getChild("message"); request.setAttribute("message", org.apache.commons.lang.StringEscapeUtils.escapeHtml(messageEle.getText())); } else { InputStream is = (InputStream) r.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); Element root = jDoc.getRootElement(); Element message = root.getChild("message"); String error = root.getText(); if (message != null) error = message.getText(); String messageStr = "Failed to create: " + error; request.setAttribute("message", org.apache.commons.lang.StringEscapeUtils.escapeHtml(messageStr)); } return SUCCESS; }
From source file:gov.nih.nci.system.web.struts.action.RestLinkAction.java
private String formatHref(String href, String className) { String resName = className.substring(className.lastIndexOf(".") + 1); int index = href.indexOf(resName); if (index == -1) return href; String preIdStr = href.substring(0, index + resName.length() + 1); //id part//w ww . j a v a 2 s . com String criteriaStr = href.substring(index + resName.length() + 1); String idStr = null; //role part int index2 = criteriaStr.indexOf("/"); String roleName = null; if (index2 != -1) { idStr = criteriaStr.substring(0, index2); roleName = criteriaStr.substring(index2 + 1, criteriaStr.length()); } else idStr = criteriaStr; String idName = null; try { idName = classCache.getClassIdName(Class.forName(className)); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (idName == null) return href; String newHref = preIdStr + "search;" + idName + "=" + idStr + (roleName != null ? "/" + roleName : ""); return newHref; }
From source file:atd.backend.Login.java
/** * Vangt het POST request van de login.jsp en controlleerd deze met de * database//from w w w . j a v a2s.co m */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String username = req.getParameter("username").toLowerCase(); try { Class.forName("org.apache.commons.codec.digest.DigestUtils"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } String pass = org.apache.commons.codec.digest.DigestUtils.sha256Hex(req.getParameter("password")); RequestDispatcher rd = null; if (UsersDAO.authUser(username, pass) || (username.equals(adminUser)) && req.getParameter("password").equals(adminPwd)) { // Controlleer of het filter een redirect gezet heeft if (req.getAttribute("redirect") == null || req.getAttribute("redirect").equals("")) { rd = req.getRequestDispatcher("/index.jsp"); } else { rd = req.getRequestDispatcher((String) req.getAttribute("redirect")); req.removeAttribute("redirect"); } req.getSession().setAttribute("username", UsersDAO.searchUser(username)); resp.addCookie(new Cookie("username", username)); java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentTime = sdf.format(dt); LogDAO.setLog(req.getRemoteAddr(), currentTime, UsersDAO.searchUser(username), null); rd.forward(req, resp); } else if (KlantenDAO.authKlant(username, pass)) { if (req.getAttribute("redirect") == null || req.getAttribute("redirect").equals("")) { rd = req.getRequestDispatcher("/index.jsp"); } else { rd = req.getRequestDispatcher((String) req.getAttribute("redirect")); req.removeAttribute("redirect"); } req.getSession().setAttribute("username", KlantenDAO.searchKlant(username)); System.out.println("klant setten"); resp.addCookie(new Cookie("username", username)); java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentTime = sdf.format(dt); LogDAO.setLog(req.getRemoteAddr(), currentTime, null, KlantenDAO.searchKlant(username)); rd.forward(req, resp); } else { rd = req.getRequestDispatcher("/login/login.jsp"); req.setAttribute("error", "<div class=\"alert alert-danger\" role=\"alert\"> <span class=\"sr-only\">Error:</span> ongeldige inlog gegevens </div>"); rd.forward(req, resp); } }