Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.codehaus.groovy.grails.commons.DefaultGrailsApplication.java

/**
 * Loads a GrailsApplication using the given ResourceLocator instance which will search for appropriate class names
 *
 *//*w w  w  . j av  a 2 s  .c om*/
public DefaultGrailsApplication(Resource[] resources) {
    this();
    for (Resource resource : resources) {

        Class<?> aClass;
        try {
            aClass = cl.loadClass(org.codehaus.groovy.grails.io.support.GrailsResourceUtils
                    .getClassName(resource.getFile().getAbsolutePath()));
        } catch (ClassNotFoundException e) {
            throw new GrailsConfigurationException(
                    "Class not found loading Grails application: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new GrailsConfigurationException(
                    "Class not found loading Grails application: " + e.getMessage(), e);
        }
        loadedClasses.add(aClass);
    }
}

From source file:org.codehaus.groovy.grails.commons.DefaultGrailsApplication.java

/**
 * Loads a GrailsApplication using the given ResourceLocator instance which will search for appropriate class names
 *
 *//*from   w  w  w  .  ja  v a  2 s .  c  o m*/
public DefaultGrailsApplication(org.codehaus.groovy.grails.io.support.Resource[] resources) {
    this();
    for (org.codehaus.groovy.grails.io.support.Resource resource : resources) {

        Class<?> aClass;
        try {
            aClass = cl.loadClass(org.codehaus.groovy.grails.io.support.GrailsResourceUtils
                    .getClassName(resource.getFile().getAbsolutePath()));
        } catch (ClassNotFoundException e) {
            throw new GrailsConfigurationException(
                    "Class not found loading Grails application: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new GrailsConfigurationException(
                    "Class not found loading Grails application: " + e.getMessage(), e);
        }
        loadedClasses.add(aClass);
    }
}

From source file:com.money.manager.ex.MainActivity.java

/**
 * this method call for classic method (show fragments)
 * /* ww  w . java 2  s  . c o  m*/
 * @param savedInstanceState
 */
public void onCreateFragments(Bundle savedInstanceState) {
    Core core = new Core(this);

    setContentView(R.layout.main_fragments_activity);

    LinearLayout fragmentDetail = (LinearLayout) findViewById(R.id.fragmentDetail);
    setDualPanel(fragmentDetail != null && fragmentDetail.getVisibility() == View.VISIBLE);
    // show home fragment
    HomeFragment fragment = (HomeFragment) getSupportFragmentManager()
            .findFragmentByTag(HomeFragment.class.getSimpleName());
    if (fragment == null) {
        // fragment create
        fragment = new HomeFragment();
        // add to stack
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragmentContent, fragment, HomeFragment.class.getSimpleName()).commit();
    } else if (core.isTablet()) {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragmentContent, fragment, HomeFragment.class.getSimpleName()).commit();
    }

    // manage fragment
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CLASS_FRAGMENT_CONTENT)) {
        String className = savedInstanceState.getString(KEY_CLASS_FRAGMENT_CONTENT);
        if (className.contains(AccountFragment.class.getSimpleName())) {
            changeFragment(Integer.parseInt(className.substring(className.indexOf("_") + 1)));
        } else {
            try {
                showFragment(Class.forName(className));
            } catch (ClassNotFoundException e) {
                Log.e(LOGCAT, e.getMessage());
            }
        }
    }
    // navigation drawer
    mDrawer = (DrawerLayout) findViewById(R.id.drawerLayout);

    // set a custom shadow that overlays the main content when the drawer opens
    if (mDrawer != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer);
            mDrawer.setDrawerListener(mDrawerToggle);
            // create drawer menu
            createDrawerMenu();
            // enable ActionBar app icon to behave as action to toggle nav drawer   
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowTitleEnabled(true);
        } else {
            mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    }
}

From source file:com.orange.mmp.api.ws.jsonrpc.SimpleJSONSerializer.java

/**
 * Replace getClassFromHint from super class to avoid using class hint
 * @param o a JSONObject or JSONArray object to get the Class type
 * @return the Class found, or null if the passed in Object is null
 *
 * @throws UnmarshallException if javaClass was not found
 *///from   ww  w  .  ja v  a2s  . co m
@SuppressWarnings("unchecked")
private Class getClass(Object o) throws UnmarshallException {
    if (o == null) {
        return null;
    }

    if (o instanceof JSONArray) {
        JSONArray arr = (JSONArray) o;
        if (arr.length() == 0) {
            //             throw new UnmarshallException("no type for empty array");
            try {
                return Class.forName("[L" + Integer.class.getName() + ";");
            } catch (ClassNotFoundException e) {
                // XXX Warning: if this block doesn't fit, just throw the following exception
                // This block is used by SynchronizeAPI, when an empty blocks list is provided 
                throw new UnmarshallException("no type for empty array");
            }
        }

        Class compClazz;
        try {
            compClazz = getClass(arr.get(0));
            int arrayLgth = arr.length();
            for (int index = 0; index < arrayLgth; index++) {
                if (!getClass(arr.get(index)).isAssignableFrom(compClazz)) {
                    return java.util.List.class;
                }
            }
        } catch (JSONException e) {
            throw (NoSuchElementException) new NoSuchElementException(e.getMessage()).initCause(e);
        }

        try {
            if (compClazz.isArray()) {
                return Class.forName("[" + compClazz.getName());
            }
            return Class.forName("[L" + compClazz.getName() + ";");
        } catch (ClassNotFoundException e) {
            throw new UnmarshallException("problem getting array type");
        }
    }
    return o.getClass();
}

From source file:com.wx3.galacdecks.Bootstrap.java

private void importRules(GameDatastore datastore, String path) throws IOException {
    Files.walk(Paths.get(path)).forEach(filePath -> {
        if (Files.isRegularFile(filePath)) {
            try {
                if (FilenameUtils.getExtension(filePath.getFileName().toString()).toLowerCase().equals("js")) {
                    String id = FilenameUtils.removeExtension(filePath.getFileName().toString());
                    List<String> lines = Files.readAllLines(filePath);
                    if (lines.size() < 3) {
                        throw new RuntimeException(
                                "Script file should have at least 3 lines: description, trigger, and code.");
                    }/*from   w w  w .j  a  v a  2 s  .  com*/
                    String description = lines.get(0).substring(2).trim();

                    String trigger = lines.get(1).substring(11).trim();
                    // Check that this actually is a valid trigger event:
                    try {
                        if (!trigger.equals(GameRules.BUFF_PHASE)) {
                            Class.forName(eventPackage + "." + trigger);
                        }

                    } catch (ClassNotFoundException e) {
                        throw new RuntimeException("No such GameEvent: " + trigger);
                    }
                    String script = String.join("\n", lines);
                    EntityRule rule = EntityRule.createRule(trigger, script, id, description);
                    datastore.createRule(rule);
                    ruleCache.put(id, rule);
                    logger.info("Imported rule " + id);
                }
            } catch (Exception e) {
                throw new RuntimeException("Failed to parse " + filePath + ": " + e.getMessage());
            }
        }
    });
}

From source file:org.apache.maven.plugins.help.EvaluateMojo.java

/**
 * @param xstreamObject not null//from  w w  w  . j a v a 2s .co  m
 * @param jarFile not null
 * @param packageFilter a package name to filter.
 */
private void addAlias(XStream xstreamObject, File jarFile, String packageFilter) {
    JarInputStream jarStream = null;
    try {
        jarStream = new JarInputStream(new FileInputStream(jarFile));
        JarEntry jarEntry = jarStream.getNextJarEntry();
        while (jarEntry != null) {
            if (jarEntry.getName().toLowerCase(Locale.ENGLISH).endsWith(".class")) {
                String name = jarEntry.getName().substring(0, jarEntry.getName().indexOf("."));
                name = name.replaceAll("/", "\\.");

                if (name.contains(packageFilter)) {
                    try {
                        Class<?> clazz = ClassUtils.getClass(name);
                        String alias = StringUtils.lowercaseFirstLetter(ClassUtils.getShortClassName(clazz));
                        xstreamObject.alias(alias, clazz);
                        if (!clazz.equals(Model.class)) {
                            xstreamObject.omitField(clazz, "modelEncoding"); // unnecessary field
                        }
                    } catch (ClassNotFoundException e) {
                        getLog().error(e);
                    }
                }
            }

            jarStream.closeEntry();
            jarEntry = jarStream.getNextJarEntry();
        }
    } catch (IOException e) {
        if (getLog().isDebugEnabled()) {
            getLog().debug("IOException: " + e.getMessage(), e);
        }
    } finally {
        IOUtil.close(jarStream);
    }
}

From source file:org.apache.wiki.attachment.AttachmentManager.java

/**
 *  Creates a new AttachmentManager.  Note that creation will never fail,
 *  but it's quite likely that attachments do not function.
 *  <p>//from www.j av a2  s.co  m
 *  <b>DO NOT CREATE</b> an AttachmentManager on your own, unless you really
 *  know what you're doing.  Just use WikiEngine.getAttachmentManager() if
 *  you're making a module for JSPWiki.
 *
 *  @param engine The wikiengine that owns this attachment manager.
 *  @param props  A list of properties from which the AttachmentManager will seek
 *  its configuration.  Typically this is the "jspwiki.properties".
 */

// FIXME: Perhaps this should fail somehow.
public AttachmentManager(WikiEngine engine, Properties props) {
    String classname;

    m_engine = engine;

    //
    //  If user wants to use a cache, then we'll use the CachingProvider.
    //
    boolean useCache = "true".equals(props.getProperty(PageManager.PROP_USECACHE));

    if (useCache) {
        classname = "org.apache.wiki.providers.CachingAttachmentProvider";
    } else {
        classname = props.getProperty(PROP_PROVIDER);
    }

    //
    //  If no class defined, then will just simply fail.
    //
    if (classname == null) {
        log.info("No attachment provider defined - disabling attachment support.");
        return;
    }

    //
    //  Create and initialize the provider.
    //
    try {
        Class<?> providerclass = ClassUtil.findClass("org.apache.wiki.providers", classname);

        m_provider = (WikiAttachmentProvider) providerclass.newInstance();

        m_provider.initialize(m_engine, props);
    } catch (ClassNotFoundException e) {
        log.error("Attachment provider class not found", e);
    } catch (InstantiationException e) {
        log.error("Attachment provider could not be created", e);
    } catch (IllegalAccessException e) {
        log.error("You may not access the attachment provider class", e);
    } catch (NoRequiredPropertyException e) {
        log.error("Attachment provider did not find a property that it needed: " + e.getMessage(), e);
        m_provider = null; // No, it did not work.
    } catch (IOException e) {
        log.error("Attachment provider reports IO error", e);
        m_provider = null;
    }
}

From source file:com.ecyrd.jspwiki.attachment.AttachmentManager.java

/**
 *  Creates a new AttachmentManager.  Note that creation will never fail,
 *  but it's quite likely that attachments do not function.
 *  <p>/*from   w w  w. j a  va2  s  . c o  m*/
 *  <b>DO NOT CREATE</b> an AttachmentManager on your own, unless you really
 *  know what you're doing.  Just use WikiEngine.getAttachmentManager() if
 *  you're making a module for JSPWiki.
 *
 *  @param engine The wikiengine that owns this attachment manager.
 *  @param props  A list of properties from which the AttachmentManager will seek
 *  its configuration.  Typically this is the "jspwiki.properties".
 */

// FIXME: Perhaps this should fail somehow.
public AttachmentManager(WikiEngine engine, Properties props) {
    String classname;

    m_engine = engine;

    //
    //  If user wants to use a cache, then we'll use the CachingProvider.
    //
    boolean useCache = "true".equals(props.getProperty(PageManager.PROP_USECACHE));

    if (useCache) {
        classname = "com.ecyrd.jspwiki.providers.CachingAttachmentProvider";
    } else {
        classname = props.getProperty(PROP_PROVIDER);
    }

    //
    //  If no class defined, then will just simply fail.
    //
    if (classname == null) {
        log.info("No attachment provider defined - disabling attachment support.");
        return;
    }

    //
    //  Create and initialize the provider.
    //
    try {
        Class<?> providerclass = ClassUtil.findClass("com.ecyrd.jspwiki.providers", classname);

        m_provider = (WikiAttachmentProvider) providerclass.newInstance();

        m_provider.initialize(m_engine, props);
    } catch (ClassNotFoundException e) {
        log.error("Attachment provider class not found", e);
    } catch (InstantiationException e) {
        log.error("Attachment provider could not be created", e);
    } catch (IllegalAccessException e) {
        log.error("You may not access the attachment provider class", e);
    } catch (NoRequiredPropertyException e) {
        log.error("Attachment provider did not find a property that it needed: " + e.getMessage(), e);
        m_provider = null; // No, it did not work.
    } catch (IOException e) {
        log.error("Attachment provider reports IO error", e);
        m_provider = null;
    }
}

From source file:hudson.UtilTest.java

@Test
public void testDeleteFile_onWindows() throws Exception {
    Assume.assumeTrue(Functions.isWindows());
    Class<?> c;//from  w  ww .j a va 2s .  c  om
    try {
        c = Class.forName("java.nio.file.FileSystemException");
    } catch (ClassNotFoundException x) {
        throw new AssumptionViolatedException("prior to JDK 7", x);
    }
    try {
        File f = tmp.newFile();
        // Test: If we cannot delete a file, we throw explaining why
        mkfiles(f);
        lockFileForDeletion(f);
        try {
            Util.deleteFile(f);
            fail("should not have been deletable");
        } catch (IOException x) {
            assertThat(calcExceptionHierarchy(x), hasItem(c));
            assertThat(x.getMessage(), containsString(f.getPath()));
        }
    } finally {
        unlockFilesForDeletion();
    }
}

From source file:be.fedict.eid.dss.model.bean.ServicesManagerSingletonBean.java

@SuppressWarnings("unchecked")
public DSSDocumentService getDocumentService(String contentType) {
    LOG.debug("getDocumentService");
    String documentServiceClassName = this.documentServiceClassNames.get(contentType);
    if (null == documentServiceClassName) {
        throw new IllegalArgumentException("unsupported content type: " + contentType);
    }//from   w w w  .  j a  v a2  s  .  co  m
    Class<? extends DSSDocumentService> documentServiceClass;
    try {
        documentServiceClass = (Class<? extends DSSDocumentService>) Class.forName(documentServiceClassName);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException("document service class not found: " + documentServiceClassName, e);
    }
    DSSDocumentService documentService;
    try {
        documentService = documentServiceClass.newInstance();
    } catch (Exception e) {
        throw new RuntimeException("could not create instance of document service: " + documentServiceClassName,
                e);
    }
    DSSDocumentContext documentContext = new ModelDSSDocumentContext(this.xmlSchemaManager,
            this.xmlStyleSheetManager, this.trustValidationService, this.configuration);
    try {
        documentService.init(documentContext, contentType);
    } catch (Exception e) {
        throw new RuntimeException("error initializing the document service: " + e.getMessage(), e);
    }
    return documentService;
}