Example usage for java.lang NoClassDefFoundError getCause

List of usage examples for java.lang NoClassDefFoundError getCause

Introduction

In this page you can find the example usage for java.lang NoClassDefFoundError getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:com.ocpsoft.pretty.faces.util.ServiceLoader.java

private S prepareInstance(Class<? extends S> serviceClass) {
    try {//from  ww w.  ja  v a 2s  .co m
        // TODO Support the SM
        Constructor<? extends S> constructor = serviceClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        return constructor.newInstance();
    } catch (NoClassDefFoundError e) {
        log.warn("Could not instantiate service class " + serviceClass.getName(), e);
        return null;
    } catch (InvocationTargetException e) {
        throw new RuntimeException("Error instantiating " + serviceClass, e.getCause());
    } catch (IllegalArgumentException e) {
        throw new RuntimeException("Error instantiating " + serviceClass, e);
    } catch (InstantiationException e) {
        throw new RuntimeException("Error instantiating " + serviceClass, e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Error instantiating " + serviceClass, e);
    } catch (SecurityException e) {
        throw new RuntimeException("Error instantiating " + serviceClass, e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException("Error instantiating " + serviceClass, e);
    }
}

From source file:org.ebayopensource.turmeric.eclipse.functional.test.ft.wsdlsvc.ConsumerFromIntfTest.java

@Test
@Ignore("failing")
public void testConsumeCalculatorSvc() throws Exception {

    // Turn on the auto-build for the builders to kick-in
    SimpleTestUtil.setAutoBuilding(true);

    try {//from ww w  . j  a  v  a 2  s.c o m
        Boolean b = createServiceFromWsdl(new File(WSDL_FILE).toURI().toURL(), namespacePart);

        Assert.assertTrue(adminName + "  creation failed", b);

        StringBuffer failMessages = ProjectArtifactValidator.getErroredFileMessage();

        ProjectArtifactValidator.getErroredFileMessage().setLength(0);
        // validate artifacts
        boolean intfMatch = ServiceSetupCleanupValidate
                .validateIntfArtifacts(WorkspaceUtil.getProject(adminName), adminName);
        Assert.assertTrue(" --- Service artifacts validation failed for " + failMessages, intfMatch);

        String consumerId = "CalcConsumer_Id";
        List<String> environment = new ArrayList<String>();
        environment.add("production");
        ConsumerFromJavaParamModel model = new ConsumerFromJavaParamModel();
        model.setBaseConsumerSrcDir("src");
        model.setClientName(adminName + "Consumer");
        ArrayList<String> list = new ArrayList<String>();
        list.add(adminName);
        model.setServiceNames(list);
        model.setParentDirectory(PARENT_DIR);
        model.setConsumerId(consumerId);
        model.setEnvironments(environment);

        SimpleTestUtil.setAutoBuilding(false);

        ServiceCreator.createConsumerFromJava(model, ProgressUtil.getDefaultMonitor(null));
        SimpleTestUtil.setAutoBuilding(true);
        // Add validation for the expected artifacts and contents..
        boolean consumerMatch = ServiceSetupCleanupValidate.validateConsumerArtifacts(
                WorkspaceUtil.getProject(adminName + "Consumer"), adminName + "Consumer");

        System.out.println(failMessages.toString());
        Assert.assertTrue(" --- Service artifacts validation failed for " + failMessages.toString(),
                consumerMatch);
        ProjectArtifactValidator.getErroredFileMessage().setLength(0);

        // we know that the CC.xml or GCC.xml is the last artifact to be
        // created
        // The project exists as
        IProject consProject = WorkspaceUtil.getProject(model.getClientName());

        consProject.build(IncrementalProjectBuilder.FULL_BUILD, ProgressUtil.getDefaultMonitor(null));
        // if project build goes through, its a successful test
    } catch (NoClassDefFoundError ex) {
        assumeNoException(ex);
    } catch (Exception ex) {
        System.out.println("--- Exception in consumeCalculatorSvc() - " + ex.getMessage());
        System.out.println("--- Exception in consumeCalculatorSvc() toString - " + ex.toString());
        System.out.println("--- Exception in consumeCalculatorSvc() getCause - " + ex.getCause().getMessage());
        Assert.fail("Exception in consumeCalculatorSvc() - " + ex.getLocalizedMessage());
    }
}