Example usage for java.lang NoClassDefFoundError NoClassDefFoundError

List of usage examples for java.lang NoClassDefFoundError NoClassDefFoundError

Introduction

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

Prototype

public NoClassDefFoundError(String s) 

Source Link

Document

Constructs a NoClassDefFoundError with the specified detail message.

Usage

From source file:Main.java

public static void checkRecyclerViewOnClassPath() {
    if (!hasRecyclerView()) {
        throw new NoClassDefFoundError(
                "RecyclerView is not on classpath, " + "make sure that you have it in your dependencies");
    }/*from  w  ww .ja  v  a 2  s . c  o  m*/
}

From source file:hudson.lifecycle.Lifecycle.java

/**
 * Gets the singleton instance./*from   w ww  . j  a  va  2 s . c  o m*/
 *
 * @return never null
 */
public synchronized static Lifecycle get() {
    if (INSTANCE == null) {
        String p = System.getProperty("hudson.lifecycle");
        if (p != null) {
            try {
                ClassLoader cl = Hudson.getInstance().getPluginManager().uberClassLoader;
                INSTANCE = (Lifecycle) cl.loadClass(p).newInstance();
            } catch (InstantiationException e) {
                InstantiationError x = new InstantiationError(e.getMessage());
                x.initCause(e);
                throw x;
            } catch (IllegalAccessException e) {
                IllegalAccessError x = new IllegalAccessError(e.getMessage());
                x.initCause(e);
                throw x;
            } catch (ClassNotFoundException e) {
                NoClassDefFoundError x = new NoClassDefFoundError(e.getMessage());
                x.initCause(e);
                throw x;
            }
        } else {
            // if run on Unix, we can do restart 
            if (!Hudson.isWindows()) {
                try {
                    INSTANCE = new UnixLifecycle();
                } catch (IOException e) {
                    LOGGER.log(Level.WARNING, "Failed to install embedded lifecycle implementation", e);
                }
            }

            // use the default one. final fallback.
            if (INSTANCE == null)
                INSTANCE = new Lifecycle() {
                };
        }
    }

    return INSTANCE;
}

From source file:gov.nih.nci.cabig.caaers.web.table.SortRowsCallbackImpl.java

public Collection sortRows(TableModel model, Collection rows) throws Exception {
    boolean sorted = model.getLimit().isSorted();

    if (!sorted) {
        return rows;
    }//from   w w w  .  ja v a  2s . com

    Sort sort = model.getLimit().getSort();
    String property = sort.getProperty();
    String sortOrder = sort.getSortOrder();

    if (StringUtils.contains(property, ".")) {
        try {
            if (sortOrder.equals(TableConstants.SORT_ASC)) {
                Collections.sort((List) rows, new NullSafeBeanComparator(property, new NullStringComparator()));
            } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
                NullSafeBeanComparator reversedNaturalOrderBeanComparator = new NullSafeBeanComparator(property,
                        new ReverseComparator(new NullStringComparator()));
                Collections.sort((List) rows, reversedNaturalOrderBeanComparator);
            }
        } catch (NoClassDefFoundError e) {
            String msg = "The column property [" + property
                    + "] is nested and requires BeanUtils 1.7 or greater for proper sorting.";
            logger.error(msg);
            throw new NoClassDefFoundError(msg); //just rethrow so it is not hidden
        }
    } else {
        if (sortOrder.equals(TableConstants.SORT_ASC)) {
            BeanComparator comparator = new BeanComparator(property, new NullStringComparator());
            Collections.sort((List) rows, comparator);
        } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
            BeanComparator reversedNaturalOrderBeanComparator = new BeanComparator(property,
                    new ReverseComparator(new NullStringComparator()));
            Collections.sort((List) rows, reversedNaturalOrderBeanComparator);
        }
    }

    return rows;
}

From source file:com.ultrapower.eoms.common.plugin.ecside.table.callback.ProcessRowsCallback.java

public Collection sortRows(TableModel model, Collection rows) throws Exception {
    boolean sorted = model.getLimit().isSorted();

    if (!sorted) {
        return rows;
    }/*from   w w  w  .  ja  v  a  2 s  .c  o  m*/

    Sort sort = model.getLimit().getSort();
    String property = sort.getProperty();
    String sortOrder = sort.getSortOrder();
        
    if (StringUtils.contains(property, ".")) {
        try {
            if (sortOrder.equals(TableConstants.SORT_ASC)) {
                Collections.sort((List) rows, new NullSafeBeanComparator(property, new NullComparator()));
            } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
                NullSafeBeanComparator reversedNaturalOrderBeanComparator = new NullSafeBeanComparator(property,
                        new ReverseComparator(new NullComparator()));
                Collections.sort((List) rows, reversedNaturalOrderBeanComparator);
            }
        } catch (NoClassDefFoundError e) {
            String msg = "The column property [" + property + "] is nested and requires BeanUtils 1.7 or greater for proper sorting.";
            logger.error(msg);
            throw new NoClassDefFoundError(msg); //just rethrow so it is not hidden
        }
    } else {
        if (sortOrder.equals(TableConstants.SORT_ASC)) {
            BeanComparator comparator = new BeanComparator(property, new NullComparator());
            Collections.sort((List) rows, comparator);
        } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
            BeanComparator reversedNaturalOrderBeanComparator = new BeanComparator(property, new ReverseComparator(new NullComparator()));
            Collections.sort((List) rows, reversedNaturalOrderBeanComparator);
        }
    }

    return rows;
}

From source file:com.googlecode.jtiger.modules.ecside.table.callback.ProcessRowsCallback.java

public Collection sortRows(TableModel model, Collection rows) throws Exception {
    boolean sorted = model.getLimit().isSorted();

    if (!sorted) {
        return rows;
    }/*w ww. jav a2 s .  c  o  m*/

    Sort sort = model.getLimit().getSort();
    String property = sort.getProperty();
    String sortOrder = sort.getSortOrder();

    if (StringUtils.contains(property, ".")) {
        try {
            if (sortOrder.equals(TableConstants.SORT_ASC)) {
                Collections.sort((List) rows, new NullSafeBeanComparator(property, new NullComparator()));
            } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
                NullSafeBeanComparator reversedNaturalOrderBeanComparator = new NullSafeBeanComparator(property,
                        new ReverseComparator(new NullComparator()));
                Collections.sort((List) rows, reversedNaturalOrderBeanComparator);
            }
        } catch (NoClassDefFoundError e) {
            String msg = "The column property [" + property
                    + "] is nested and requires BeanUtils 1.7 or greater for proper sorting.";
            logger.error(msg);
            throw new NoClassDefFoundError(msg); //just rethrow so it is not hidden
        }
    } else {
        if (sortOrder.equals(TableConstants.SORT_ASC)) {
            BeanComparator comparator = new BeanComparator(property, new NullComparator());
            Collections.sort((List) rows, comparator);
        } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
            BeanComparator reversedNaturalOrderBeanComparator = new BeanComparator(property,
                    new ReverseComparator(new NullComparator()));
            Collections.sort((List) rows, reversedNaturalOrderBeanComparator);
        }
    }

    return rows;
}

From source file:spring.osgi.context.internal.classloader.BundleDelegatingClassLoader.java

protected Class findClass(String name) throws ClassNotFoundException {
    try {/*  w  ww . j  a va 2s . c o  m*/
        return this.backingBundle.loadClass(name);
    } catch (ClassNotFoundException cnfe) {

        throw new ClassNotFoundException(
                name + " not found from bundle [" + backingBundle.getSymbolicName() + "]", cnfe);
    } catch (NoClassDefFoundError ncdfe) {
        // This is almost always an error
        // This is caused by a dependent class failure,
        // so make sure we search for the right one.
        NoClassDefFoundError e = new NoClassDefFoundError(
                name + " not found from bundle [" + backingBundle + "]");
        e.initCause(ncdfe);
        throw e;
    }
}

From source file:Operacional.Janela2.java

static Class class$(String s) {
    try {/*w  w  w  .  jav  a2  s  .  c  o  m*/
        return Class.forName(s);
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block   
        e.printStackTrace();
    }
    ClassNotFoundException classnotfoundexception = null;
    throw new NoClassDefFoundError(classnotfoundexception.getMessage());
}

From source file:org.apache.hadoop.yarn.client.api.impl.TestYarnClient.java

@Test
public void testStartTimelineClientWithErrors() throws Exception {
    // If timeline client failed to init with a NoClassDefFoundError
    // it should be wrapped with an informative error message
    testCreateTimelineClientWithError(1.5f, true, false,
            new NoClassDefFoundError("Mock a NoClassDefFoundError"), new CreateTimelineClientErrorVerifier(1) {
                @Override//from w w w. jav  a2  s  .c  om
                public void verifyError(Throwable e) {
                    Assert.assertTrue(e instanceof NoClassDefFoundError);
                    Assert.assertTrue(e.getMessage() != null
                            && e.getMessage().contains(YarnConfiguration.TIMELINE_SERVICE_ENABLED));
                }
            });

    // Disable timeline service for this client,
    // yarn client will not fail when such error happens
    testCreateTimelineClientWithError(1.5f, false, false,
            new NoClassDefFoundError("Mock a NoClassDefFoundError"), new CreateTimelineClientErrorVerifier(0) {
                @Override
                public void verifyError(Throwable e) {
                    Assert.fail("NoClassDefFoundError while creating timeline client"
                            + "should be tolerated when timeline service is disabled.");
                }
            });

    // Set best-effort to true, verify an error is still fatal
    testCreateTimelineClientWithError(1.5f, true, true, new NoClassDefFoundError("Mock a NoClassDefFoundError"),
            new CreateTimelineClientErrorVerifier(1) {
                @Override
                public void verifyError(Throwable e) {
                    Assert.assertTrue(e instanceof NoClassDefFoundError);
                    Assert.assertTrue(e.getMessage() != null
                            && e.getMessage().contains(YarnConfiguration.TIMELINE_SERVICE_ENABLED));
                }
            });

    // Set best-effort to false, verify that an exception
    // causes the client to fail
    testCreateTimelineClientWithError(1.5f, true, false,
            new IOException("ATS v1.5 client initialization failed."),
            new CreateTimelineClientErrorVerifier(1) {
                @Override
                public void verifyError(Throwable e) {
                    Assert.assertTrue(e instanceof IOException);
                }
            });

    // Set best-effort to true, verify that an normal exception
    // won't fail the entire client
    testCreateTimelineClientWithError(1.5f, true, true,
            new IOException("ATS v1.5 client initialization failed."),
            new CreateTimelineClientErrorVerifier(0) {
                @Override
                public void verifyError(Throwable e) {
                    Assert.fail("IOException while creating timeline client"
                            + "should be tolerated when best effort is true");
                }
            });
}

From source file:org.apache.hadoop.yarn.client.api.impl.YarnClientImpl.java

@VisibleForTesting
org.apache.hadoop.security.token.Token<TimelineDelegationTokenIdentifier> getTimelineDelegationToken()
        throws IOException, YarnException {
    try {//from   www .j  av a 2 s  .com
        // Only reachable when both security and timeline service are enabled.
        if (timelineClient == null) {
            synchronized (this) {
                if (timelineClient == null) {
                    timelineClient = createTimelineClient();
                    timelineClient.init(getConfig());
                    timelineClient.start();
                }
            }
        }
        return timelineClient.getDelegationToken(timelineDTRenewer);
    } catch (Exception e) {
        if (timelineServiceBestEffort) {
            LOG.warn("Failed to get delegation token from the timeline server: " + e.getMessage());
            return null;
        }
        throw e;
    } catch (NoClassDefFoundError e) {
        NoClassDefFoundError wrappedError = new NoClassDefFoundError(
                e.getMessage() + ". It appears that the timeline client "
                        + "failed to initiate because an incompatible dependency "
                        + "in classpath. If timeline service is optional to this "
                        + "client, try to work around by setting " + YarnConfiguration.TIMELINE_SERVICE_ENABLED
                        + " to false in client configuration.");
        wrappedError.setStackTrace(e.getStackTrace());
        throw wrappedError;
    }
}

From source file:org.beangle.model.persist.hibernate.internal.BundleDelegatingClassLoader.java

protected Class<?> findClass(String name) throws ClassNotFoundException {
    try {//from  w  w w . j  a v  a2  s  . c om
        return this.backingBundle.loadClass(name);
    } catch (ClassNotFoundException cnfe) {
        // DebugUtils.debugClassLoading(backingBundle, name, null);
        throw new ClassNotFoundException(
                name + " not found from bundle [" + backingBundle.getSymbolicName() + "]", cnfe);
    } catch (NoClassDefFoundError ncdfe) {
        // This is almost always an error
        // This is caused by a dependent class failure,
        // so make sure we search for the right one.
        String cname = ncdfe.getMessage().replace('/', '.');
        // DebugUtils.debugClassLoading(backingBundle, cname, name);
        NoClassDefFoundError e = new NoClassDefFoundError(
                cname + " not found from bundle [" + backingBundle + "]");
        e.initCause(ncdfe);
        throw e;
    }
}