List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:org.lamop.riche.services.ImportServiceImpl.java
private void initConnectionRiche() { try {/*from w w w . j a v a2 s .c o m*/ Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { } try { connexionRiche = DriverManager.getConnection("jdbc:mysql://localhost:3306/riche", "root", "Sidll4LP"); } catch (SQLException e) { e.printStackTrace(); } }
From source file:net.sourceforge.pmd.util.fxdesigner.util.beans.XmlInterfaceVersion1.java
@Override protected SimpleBeanModelNode parseSettingsOwnerNode(Element nodeElement) { Class<?> clazz;//from w ww .j a va2 s . co m try { clazz = Class.forName(nodeElement.getAttribute(SCHEMA_NODE_CLASS_ATTRIBUTE)); } catch (ClassNotFoundException e) { return null; } SimpleBeanModelNode node = new SimpleBeanModelNode(clazz); for (Element setting : getChildrenByTagName(nodeElement, SCHEMA_PROPERTY_ELEMENT)) { parseSingleProperty(setting, node); } for (Element child : getChildrenByTagName(nodeElement, SCHEMA_NODE_ELEMENT)) { try { if (node.getChildrenByType() .get(Class.forName(child.getAttribute(SCHEMA_NODE_CLASS_ATTRIBUTE))) == null) { // FIXME node.addChild(parseSettingsOwnerNode(child)); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } for (Element seq : getChildrenByTagName(nodeElement, SCHEMA_NODESEQ_ELEMENT)) { parseNodeSeq(seq, node); } return node; }
From source file:org.apache.hadoop.hbase.filter.ParseFilter.java
/** * Constructs a filter object given a simple filter expression * <p>//from w w w . j a v a 2 s. c o m * @param filterStringAsByteArray filter string given by the user * @return filter object we constructed */ public Filter parseSimpleFilterExpression(byte[] filterStringAsByteArray) throws CharacterCodingException { String filterName = Bytes.toString(getFilterName(filterStringAsByteArray)); ArrayList<byte[]> filterArguments = getFilterArguments(filterStringAsByteArray); if (!filterHashMap.containsKey(filterName)) { throw new IllegalArgumentException("Filter Name " + filterName + " not supported"); } try { filterName = filterHashMap.get(filterName); Class<?> c = Class.forName(filterName); Class<?>[] argTypes = new Class[] { ArrayList.class }; Method m = c.getDeclaredMethod("createFilterFromArguments", argTypes); return (Filter) m.invoke(null, filterArguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } throw new IllegalArgumentException("Incorrect filter string " + new String(filterStringAsByteArray)); }
From source file:com.sldeditor.test.SLDTestRunner.java
/** * Run the test// w w w. j av a 2 s . c o m * * @param folder the folder * @param testConfig the test config */ public void runTest(String folder, String testConfig) { // read JSON file data as String String fullPath = "/" + folder + "/test/" + testConfig; SldEditorTest testSuite = (SldEditorTest) ParseXML.parseFile("", fullPath, SCHEMA_RESOURCE, SldEditorTest.class); Assert.assertNotNull("Failed to read test config file : " + fullPath, testSuite); String testsldfile = testSuite.getTestsldfile(); if (!testsldfile.startsWith("/")) { testsldfile = "/" + testsldfile; } System.out.println("Opening : " + testsldfile); List<XMLVendorOption> xmlVendorOptionList = testSuite.getVendorOption(); if ((xmlVendorOptionList != null) && !xmlVendorOptionList.isEmpty()) { List<VersionData> versionDataList = new ArrayList<VersionData>(); for (XMLVendorOption vo : xmlVendorOptionList) { try { String vendorOptionClassName = vo.getClassType().trim(); Class<?> vendorOptionClass = Class.forName(vendorOptionClassName); VersionData versionData = VersionData.decode(vendorOptionClass, vo.getVersion()); versionDataList.add(versionData); } catch (ClassNotFoundException e) { e.printStackTrace(); } } if (!versionDataList.contains(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData())) { versionDataList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData()); } sldEditor.setVendorOptions(versionDataList); } InputStream inputStream = SLDTestRunner.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); sldEditor.openFile(f.toURI().toURL()); } catch (IOException e1) { e1.printStackTrace(); } GraphicPanelFieldManager mgr = sldEditor.getFieldDataManager(); for (XMLPanelTest test : testSuite.getPanelTests()) { XMLSetup selectedItem = test.getSetup(); TreeSelectionData selectionData = new TreeSelectionData(); selectionData.setLayerIndex(getXMLValue(selectedItem.getLayer())); selectionData.setStyleIndex(getXMLValue(selectedItem.getStyle())); selectionData.setFeatureTypeStyleIndex(getXMLValue(selectedItem.getFeatureTypeStyle())); selectionData.setRuleIndex(getXMLValue(selectedItem.getRule())); selectionData.setSymbolizerIndex(getXMLValue(selectedItem.getSymbolizer())); selectionData.setSymbolizerDetailIndex(getXMLValue(selectedItem.getSymbolizerDetail())); try { selectionData.setSelectedPanel(Class.forName(selectedItem.getExpectedPanel())); } catch (ClassNotFoundException e1) { Assert.fail("Unknown class : " + selectedItem.getExpectedPanel()); } boolean result = sldEditor.selectTreeItem(selectionData); Assert.assertTrue("Failed to select tree item", result); PopulateDetailsInterface panel = sldEditor.getSymbolPanel(); String panelClassName = panel.getClass().getName(); Assert.assertEquals(panelClassName, selectedItem.getExpectedPanel()); Assert.assertEquals("Check panel data present", panel.isDataPresent(), selectedItem.isEnabled()); Class<?> panelId = null; try { panelId = Class.forName(selectedItem.getExpectedPanel()); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (test.getFieldTests() != null) { for (XMLFieldTest testItem : test.getFieldTests()) { if (testItem != null) { if (testItem.getDisabledOrLiteralStringOrLiteralInt() != null) { for (Object xmlTestValueObj : testItem.getDisabledOrLiteralStringOrLiteralInt()) { if (xmlTestValueObj instanceof XMLSetMultiOptionGroup) { XMLSetMultiOptionGroup testValue = (XMLSetMultiOptionGroup) xmlTestValueObj; GroupIdEnum groupId = testValue.getMultiOptionGroupId(); String outputText = "Checking multioption group : " + groupId; System.out.println(outputText); Assert.assertNotNull(outputText, groupId); MultiOptionGroup multiOptionGroup = mgr.getMultiOptionGroup(panelId, groupId); Assert.assertNotNull(panelId.getName() + "/" + groupId + " multi option group should exist", multiOptionGroup); multiOptionGroup.setOption(testValue.getOption()); OptionGroup optionGroupSelected = multiOptionGroup.getSelectedOptionGroup(); Assert.assertTrue(groupId + " should be set", optionGroupSelected.getId() == testValue.getOption()); } else if (xmlTestValueObj instanceof XMLSetGroup) { XMLSetGroup testValue = (XMLSetGroup) xmlTestValueObj; GroupIdEnum groupId = testValue.getGroupId(); String outputText = "Checking group : " + groupId; System.out.println(outputText); Assert.assertNotNull(outputText, groupId); GroupConfig groupConfig = mgr.getGroup(panelId, groupId); Assert.assertNotNull( panelId.getName() + "/" + groupId + " group should exist", groupConfig); groupConfig.enable(testValue.isEnable()); Assert.assertTrue(groupId + " should be set", groupConfig.isPanelEnabled() == testValue.isEnable()); } else { XMLFieldBase testValue = (XMLFieldBase) xmlTestValueObj; FieldId fieldId = new FieldId(testValue.getField()); String outputText = "Checking : " + fieldId; System.out.println(outputText); Assert.assertNotNull(outputText, fieldId); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } FieldConfigBase fieldConfig = mgr.getData(panelId, fieldId); Assert.assertNotNull(String.format("Failed to field panel %s field %s", selectedItem.getExpectedPanel(), fieldId), fieldConfig); if (testValue instanceof XMLSetFieldLiteralBase) { XMLSetFieldLiteralInterface testInterface = (XMLSetFieldLiteralInterface) testValue; testInterface.accept(fieldConfig, fieldId); if (!((XMLSetFieldLiteralBase) testValue).isIgnoreCheck()) { String sldContentString = sldEditor.getSLDString(); boolean actualResult = testOutput.testValue(sldContentString, selectionData, testValue.getField(), testValue); Assert.assertTrue(fieldId + " should be set", actualResult); } } else if (testValue instanceof XMLSetFieldAttribute) { XMLSetFieldLiteralInterface testInterface = (XMLSetFieldLiteralInterface) testValue; testInterface.accept(fieldConfig, fieldId); String sldContentString = sldEditor.getSLDString(); boolean actualResult = testOutput.testAttribute(sldContentString, selectionData, testValue.getField(), (XMLSetFieldAttribute) testValue); Assert.assertTrue(fieldId + " should be set", actualResult); } else if (testValue instanceof XMLFieldDisabled) { Assert.assertFalse(fieldId + " should be disabled", fieldConfig.isEnabled()); } else { Assert.assertTrue(fieldId + " should be enabled", fieldConfig.isEnabled()); Expression expression = null; if (fieldConfig.isValueOnly()) { String expectedValue = ""; if (testValue instanceof XMLFieldLiteralBase) { Object literalValue = getLiteralValue( (XMLFieldLiteralBase) testValue); expectedValue = String.valueOf(literalValue); } else if (testValue instanceof XMLFieldAttribute) { expectedValue = ((XMLFieldAttribute) testValue).getAttribute(); } else if (testValue instanceof XMLFieldExpression) { expectedValue = ((XMLFieldExpression) testValue) .getExpression(); } else { Assert.fail(fieldId + " has unsupported type " + testValue.getClass().getName()); } String actualValue = fieldConfig.getStringValue(); String msg = String.format("%s Expected : '%s' Actual : '%s'", outputText, expectedValue, actualValue); boolean condition; if (comparingFilename(fieldId)) { condition = actualValue.endsWith(expectedValue); } else { condition = (expectedValue.compareTo(actualValue) == 0); } Assert.assertTrue(msg, condition); } else { if (colourFieldsList.contains(fieldId.getFieldId())) { FieldConfigColour fieldColour = (FieldConfigColour) fieldConfig; expression = fieldColour.getColourExpression(); } else { expression = fieldConfig.getExpression(); if (fieldId.getFieldId() == FieldIdEnum.SYMBOL_TYPE) { String string = expression.toString(); expression = ff .literal(string.replace(File.separatorChar, '/')); } else if (fieldId.getFieldId() == FieldIdEnum.FONT_FAMILY) { // Handle the case where a font is not available on all operating systems String string = expression.toString(); if (string.compareToIgnoreCase(DEFAULT_FONT) != 0) { expression = ff.literal(getFontForOS()); System.out.println("Updated font family to test for : " + expression.toString()); } } } if (expression != null) { if (testValue instanceof XMLFieldLiteralBase) { Object literalValue = getLiteralValue( (XMLFieldLiteralBase) testValue); if (literalValue.getClass() == Double.class) { checkLiteralValue(outputText, expression, (Double) literalValue); } else if (literalValue.getClass() == Integer.class) { checkLiteralValue(outputText, expression, (Integer) literalValue); } else if (literalValue.getClass() == String.class) { if (fieldId.getFieldId() == FieldIdEnum.FONT_FAMILY) { // Handle the case where a font is not available on all operating systems checkLiteralValue(outputText, expression, getFontForOS()); } else { checkLiteralValue(outputText, expression, (String) literalValue); } } } } else { String actualValue; String expectedValue = fieldConfig.getStringValue(); Object literalValue = getLiteralValue( (XMLFieldLiteralBase) testValue); if (literalValue.getClass() == Double.class) { actualValue = String.valueOf((Double) literalValue); } else if (literalValue.getClass() == Integer.class) { actualValue = String.valueOf((Integer) literalValue); } else if (literalValue.getClass() == String.class) { actualValue = (String) literalValue; } else { actualValue = ""; } String msg = String.format("%s Expected : '%s' Actual : '%s'", outputText, expectedValue, actualValue); boolean condition = (expectedValue.compareTo(actualValue) == 0); Assert.assertTrue(msg, condition); } } } } } } } } } } } JFrame frame = sldEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); }
From source file:org.lamop.riche.services.ImportServiceImpl.java
private void initConnection() { try {//from ww w. ja v a2 s . c o m Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { } try { connexion = DriverManager.getConnection( "jdbc:mysql://localhost:3306/riche_existant?allowMultiQueries=true", "root", "Sidll4LP"); } catch (SQLException e) { e.printStackTrace(); } }
From source file:org.lamop.riche.services.ImportServiceImpl.java
private void initConnection2() { try {/* w w w .j a v a 2 s.c o m*/ Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { } try { connexion2 = DriverManager.getConnection( "jdbc:mysql://localhost:3306/riche_existant?allowMultiQueries=true", "root", "Sidll4LP"); } catch (SQLException e) { e.printStackTrace(); } }
From source file:it.polimi.hegira.transformers.CassandraTransformer.java
/** * This method maps properties of the metamodel into Cassandra columns. * Before deserializing the value it checks if the data type is supported in Cassandra. * If it is supported the value is deserialized and the type converted to one of the types supported by Cassandra. * If it is NOT supported the value is kept serialized. In this case a new column with the following structure * is added: name: <Column_name>"_Type", value: <the original data type> * /*from w w w .j a v a2 s . co m*/ * @param cassandraModel * @param model */ private void mapColumns(CassandraModel cassandraModel, Metamodel model) { Iterator<String> columnFamilyIterator = model.getColumnFamiliesIterator(); while (columnFamilyIterator.hasNext()) { String columnFamily = columnFamilyIterator.next(); //get the properties contained in the actual column family List<Column> columnsMeta = model.getColumns().get(columnFamily); if (columnsMeta != null) { for (Column column : columnsMeta) { CassandraColumn cassandraColumn = new CassandraColumn(); cassandraColumn.setColumnName(column.getColumnName()); cassandraColumn.setIndexed(column.isIndexable()); String javaType = column.getColumnValueType(); try { if (!CassandraTypesUtils.isSupportedCollection(javaType)) { setValueAndSimpleType(cassandraColumn, column.getColumnValue(), javaType); } else { String collectioType = CassandraTypesUtils.getCollectionType(javaType); if (collectioType.equals("Map")) { String type1 = CassandraTypesUtils.getFirstSimpleType(javaType); String type2 = CassandraTypesUtils.getSecondSimpleType(javaType); CassandraTypesUtils.checkIfSupported(type1); CassandraTypesUtils.checkIfSupported(type2); } else { String subType = javaType.substring(javaType.indexOf("<") + 1, javaType.indexOf(">")); CassandraTypesUtils.checkIfSupported(subType); } deserializeCollection(cassandraColumn, column.getColumnValue(), javaType); CassandraTypesUtils.translateCollectionType(cassandraColumn, javaType); } } catch (ClassNotFoundException e) { //leave the value serialized and wrap it in a ByteBuffer cassandraColumn.setColumnValue(ByteBuffer.wrap(column.getColumnValue())); cassandraColumn.setValueType("blob"); //create and add to the row a column containing the type NOT supported cassandraModel.addColumn(createTypeColumn(column)); } catch (IOException e) { e.printStackTrace(); } cassandraModel.addColumn(cassandraColumn); } } } }
From source file:com.app.server.EJBDeployer.java
public void scanJar(FileObject jarFile, HashSet<Class<?>>[] classanotwith, Class[] annot, ClassLoader cL) throws FileSystemException { //FileObject[] childs=jarFile.getChildren(); //for(FileObject child:childs){ FileObject[] classes = jarFile.findFiles(new FileSelector() { @Override// w w w.ja v a 2 s . c om public boolean includeFile(FileSelectInfo arg0) throws Exception { return arg0.getFile().getName().getBaseName().endsWith(".class"); } @Override public boolean traverseDescendents(FileSelectInfo arg0) throws Exception { // TODO Auto-generated method stub return true; } }); //} int index = 0; for (FileObject cls : classes) { try { Class<?> clz = cL.loadClass(cls.getURL().toURI().toString() .replace(jarFile.getURL().toURI().toString(), "").replace("/", ".").replace(".class", "")); index = 0; for (Class annotclz : annot) { if (clz.getAnnotation(annotclz) != null) { classanotwith[index].add(clz); } index++; } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.nick.scalpel.core.opt.BeanFactory.java
@SuppressWarnings({ "unchecked", "TryWithIdenticalCatches" }) Object createBean(String clzName) { Class clz;// ww w . j av a 2 s. co m try { clz = Class.forName(clzName); } catch (ClassNotFoundException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); return null; } // Find empty constructor. Constructor constructor = null; try { constructor = clz.getDeclaredConstructor(); } catch (NoSuchMethodException e) { logE("No empty constructor for:" + clzName); } if (constructor != null) { makeAccessible(constructor); try { return constructor.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } catch (InvocationTargetException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } } logD("Can not find empty Constructor for class:" + clzName); // Find Context constructor. try { constructor = clz.getDeclaredConstructor(Context.class); } catch (NoSuchMethodException e) { logE("No context-ed constructor for:" + clzName); } if (constructor != null) { makeAccessible(constructor); try { return constructor.newInstance(mContext); } catch (InstantiationException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } catch (IllegalAccessException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } catch (InvocationTargetException e) { logE("Error when create bean for:" + clzName + "\n" + Log.getStackTraceString(e)); } } logE("Failed to create bean for:" + clzName); return null; }
From source file:org.apache.hadoop.mapred.nativetask.kvtest.TestInputFile.java
public void createSequenceTestFile(String filepath, int base, byte start) throws Exception { LOG.info("creating file " + filepath + "(" + filesize + " bytes)"); LOG.info(keyClsName + " " + valueClsName); Class<?> tmpkeycls, tmpvaluecls; try {//from w w w.ja va2 s. c o m tmpkeycls = Class.forName(keyClsName); } catch (final ClassNotFoundException e) { throw new Exception("key class not found: ", e); } try { tmpvaluecls = Class.forName(valueClsName); } catch (final ClassNotFoundException e) { throw new Exception("key class not found: ", e); } try { final Path outputfilepath = new Path(filepath); final ScenarioConfiguration conf = new ScenarioConfiguration(); writer = SequenceFile.createWriter(conf, SequenceFile.Writer.file(outputfilepath), SequenceFile.Writer.keyClass(tmpkeycls), SequenceFile.Writer.valueClass(tmpvaluecls)); } catch (final Exception e) { e.printStackTrace(); } int tmpfilesize = this.filesize; while (tmpfilesize > DATABUFSIZE) { nextRandomBytes(databuf, base, start); final int size = flushBuf(DATABUFSIZE); tmpfilesize -= size; } nextRandomBytes(databuf, base, start); flushBuf(tmpfilesize); if (writer != null) { IOUtils.closeStream(writer); } else { throw new Exception("no writer to create sequenceTestFile!"); } }