Example usage for java.lang NoClassDefFoundError getMessage

List of usage examples for java.lang NoClassDefFoundError getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.jsp.happyaxis_jsp.java

/**
 * probe for a class, print an error message is missing
 * @param out stream to print stuff//  w w w . j  a  va 2 s  .co m
 * @param category text like "warning" or "error"
 * @param classname class to look for
 * @param jarFile where this class comes from
 * @param errorText extra error text
 * @param homePage where to d/l the library
 * @return the number of missing classes
 * @throws IOException
 */
int probeClass(JspWriter out, String category, String classname, String jarFile, String description,
        String errorText, String homePage) throws IOException {
    try {
        Class clazz = classExists(classname);
        if (clazz == null) {
            String url = "";
            if (homePage != null) {
                url = getMessage("seeHomepage", homePage, homePage);
            }
            out.write(getMessage("couldNotFound", category, classname, jarFile, errorText, url));
            return 1;
        } else {
            String location = getLocation(out, clazz);

            if (location == null) {
                out.write("<li>" + getMessage("foundClass00", description, classname) + "</li><br>");
            } else {
                out.write("<li>" + getMessage("foundClass01", description, classname, location) + "</li><br>");
            }
            return 0;
        }
    } catch (NoClassDefFoundError ncdfe) {
        String url = "";
        if (homePage != null) {
            url = getMessage("seeHomepage", homePage, homePage);
        }
        out.write(getMessage("couldNotFoundDep", category, classname, errorText, url));
        out.write(getMessage("theRootCause", ncdfe.getMessage(), classname));
        return 1;
    }
}

From source file:com.sap.prd.mobile.ios.mios.XCodeVerificationCheckMojo.java

private Exception performCheck(ClassRealm verificationCheckRealm, final Check checkDesc)
        throws MojoExecutionException {

    getLog().info(String.format("Performing verification check '%s'.", checkDesc.getClazz()));

    if (getLog().isDebugEnabled()) {

        final Charset defaultCharset = Charset.defaultCharset();
        final ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
        final PrintStream ps;
        try {//from   ww  w  . ja v a 2s .c  o  m
            ps = new PrintStream(byteOs, true, defaultCharset.name());
        } catch (UnsupportedEncodingException ex) {
            throw new MojoExecutionException(
                    String.format("Charset '%s' cannot be found.", defaultCharset.name()));
        }

        try {
            verificationCheckRealm.display(ps);
            ps.close();
            getLog().debug(String.format("Using classloader for loading verification check '%s':%s%s",
                    checkDesc.getClazz(), System.getProperty("line.separator"),
                    new String(byteOs.toByteArray(), defaultCharset)));
        } finally {
            IOUtils.closeQuietly(ps);
        }
    }

    try {
        final Class<?> verificationCheckClass = Class.forName(checkDesc.getClazz(), true,
                verificationCheckRealm);

        getLog().debug(String.format("Verification check class %s has been loaded by %s.",
                verificationCheckClass.getName(), verificationCheckClass.getClassLoader()));
        getLog().debug(String.format("Verification check super class %s has been loaded by %s.",
                verificationCheckClass.getSuperclass().getName(),
                verificationCheckClass.getSuperclass().getClassLoader()));
        getLog().debug(String.format("%s class used by this class (%s) has been loaded by %s.",
                VerificationCheck.class.getName(), this.getClass().getName(),
                VerificationCheck.class.getClassLoader()));

        for (final String configuration : getConfigurations()) {
            for (final String sdk : getSDKs()) {
                getLog().info(
                        String.format("Executing verification check: '%s' for configuration '%s' and sdk '%s'.",
                                verificationCheckClass.getName(), configuration, sdk));
                final VerificationCheck verificationCheck = (VerificationCheck) verificationCheckClass
                        .newInstance();
                verificationCheck
                        .setXcodeContext(getXCodeContext(SourceCodeLocation.WORKING_COPY, configuration, sdk));
                verificationCheck.setMavenProject(project);
                verificationCheck.setEffectiveBuildSettings(new EffectiveBuildSettings());
                try {
                    verificationCheck.check();
                } catch (VerificationException ex) {
                    return ex;
                } catch (RuntimeException ex) {
                    return ex;
                }
            }
        }
        return null;
    } catch (ClassNotFoundException ex) {
        throw new MojoExecutionException("Could not load verification check '" + checkDesc.getClazz()
                + "'. May be your classpath has not been properly extended. "
                + "Provide the GAV of the project containing the check as attributes as part of the check defintion in the check configuration file.",
                ex);
    } catch (NoClassDefFoundError err) {
        getLog().error(String.format(
                "Could not load verification check '%s'. "
                        + "May be your classpath has not been properly extended. "
                        + "Additional dependencies need to be declard inside the check definition file: %s",
                checkDesc.getClazz(), err.getMessage()), err);
        throw err;
    } catch (InstantiationException ex) {
        throw new MojoExecutionException(String.format("Could not instanciate verification check '%s': %s",
                checkDesc.getClazz(), ex.getMessage()), ex);
    } catch (IllegalAccessException ex) {
        throw new MojoExecutionException(String.format("Could not access verification check '%s': %s",
                checkDesc.getClazz(), ex.getMessage()), ex);
    }

}

From source file:com.jaspersoft.jasperserver.war.action.DataSourceAction.java

public Event uploadJDBCDrivers(RequestContext context) throws Exception {
    String driverClassName = context.getRequestParameters().get("className");
    if (driverClassName == null || driverClassName.isEmpty()) {
        throw new Exception("Class name is empty.");
    }//from ww  w . j av a 2  s .  c  om

    Map<String, byte[]> driverFilesData = new HashMap<String, byte[]>();

    int i = 0;
    MultipartFile multipartFile = context.getRequestParameters().getMultipartFile(UPLOAD_DRIVER_PREFIX + i);
    while (multipartFile != null) {
        driverFilesData.put(multipartFile.getOriginalFilename(), multipartFile.getBytes());

        i++;
        multipartFile = context.getRequestParameters().getMultipartFile(UPLOAD_DRIVER_PREFIX + i);
    }

    String errorMessage = "";
    try {
        jdbcDriverService.setDriver(driverClassName, driverFilesData);
    } catch (NoClassDefFoundError e) {
        errorMessage = messages.getMessage("resource.dataSource.jdbc.classNotFound",
                new String[] { e.getMessage() }, LocaleContextHolder.getLocale());
        logger.error(errorMessage);
    } catch (ClassNotFoundException e) {
        errorMessage = messages.getMessage("resource.dataSource.jdbc.classNotFound",
                new String[] { e.getMessage() }, LocaleContextHolder.getLocale());
        logger.error(errorMessage);
    } catch (Exception e) {
        errorMessage = e.getMessage();
        logger.error(errorMessage);
    }

    Map<String, Map<String, Object>> availableDrivers = getAvailableJdbcDrivers();

    JSONObject json = new JSONObject();
    json.put("result", isEmpty(errorMessage));
    json.put("errorMessage", errorMessage);
    json.put(JDBC_DRIVERS_JSON_KEY, JSONUtil.toJSON(availableDrivers));
    context.getRequestScope().put(AJAX_RESPONSE_MODEL, json.toString());
    context.getFlowScope().put(JDBC_DRIVERS_JSON_KEY, JSONUtil.toJSON(availableDrivers));

    return success();
}

From source file:org.settings4j.config.DOMConfigurator.java

/**
 * Used internally to parse an objectResolver element.
 *
 * @param objectResolverElement//from  ww  w.  j a va  2  s  .c  o  m
 *        The XML Object resolver Element.
 * @return The ObjectResolver instance.
 */
protected ObjectResolver parseObjectResolver(final Element objectResolverElement) {
    final String objectResolverName = objectResolverElement.getAttribute(NAME_ATTR);

    ObjectResolver objectResolver;

    final String className = objectResolverElement.getAttribute(CLASS_ATTR);

    LOG.debug("Desired ObjectResolver class: [{}]", className);
    try {
        final Class<?> clazz = loadClass(className);
        final Constructor<?> constructor = clazz.getConstructor();
        objectResolver = (ObjectResolver) constructor.newInstance();
    } catch (final Exception oops) {
        LOG.error("Could not retrieve objectResolver [{}]. Reported error follows.", objectResolverName, oops);
        return null;
    } catch (final NoClassDefFoundError e) {
        LOG.warn(
                "The ObjectResolver '{}' cannot be created. There are not all required Libraries inside the Classpath: {}",
                objectResolverName, e.getMessage(), e);
        return null;
    }

    // get connectors for ExpressionLanguage validation
    final Connector[] connectors = getConnectors(objectResolverElement);

    Filter filter = null;
    // Setting up a objectResolver needs to be an atomic operation, in order
    // to protect potential settings operations while settings
    // configuration is in progress.
    synchronized (objectResolver) {

        final NodeList children = objectResolverElement.getChildNodes();
        final int length = children.getLength();

        for (int loop = 0; loop < length; loop++) {
            final Node currentNode = children.item(loop);

            if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
                final Element currentElement = (Element) currentNode;
                final String tagName = currentElement.getTagName();

                if (tagName.equals(CONNECTOR_REF_TAG)) {
                    LOG.debug(LOG_DEBUG_CONNECTOR_REF, CONNECTOR_REF_TAG);
                } else if (tagName.equals(OBJECT_RESOLVER_REF_TAG)) {
                    final Element objectResolverRef = (Element) currentNode;
                    final ObjectResolver subObjectResolver = findObjectResolverByReference(objectResolverRef);
                    objectResolver.addObjectResolver(subObjectResolver);

                } else if (tagName.equals(PARAM_TAG)) {
                    setParameter(currentElement, objectResolver, connectors);
                } else if (tagName.equals(FILTER_TAG)) {
                    final Element filterElement = (Element) currentNode;
                    filter = parseFilter(filterElement);
                } else {
                    quietParseUnrecognizedElement(objectResolver, currentElement);
                }
            }
        }

        final String isCachedValue = objectResolverElement.getAttribute(CACHED_ATTR);
        final Boolean isCached = (Boolean) subst(isCachedValue, null, Boolean.class);
        if (BooleanUtils.isTrue(isCached)) {
            if (objectResolver instanceof AbstractObjectResolver) {
                ((AbstractObjectResolver) objectResolver).setCached(isCached.booleanValue());
            } else {
                LOG.warn("Only AbstractObjectResolver can use the attribute cached=\"true\" ");
                // TODO hbrabenetz 21.05.2008 : extract setCached into seperate Interface.
            }
        }

        if (filter != null) {
            objectResolver = new FilteredObjectResolverWrapper(objectResolver, filter);
        }
    }

    return objectResolver;
}

From source file:org.rivalry.swingui.RivalryUI.java

/**
 * Generic registration with the Mac OS X application menu. Checks the platform, then attempts to register with the
 * Apple EAWT. This method calls OSXAdapter.registerMacOSXApplication() and OSXAdapter.enablePrefs(). See
 * OSXAdapter.java for the signatures of these methods.
 *//* ww w .  j  a  v  a  2 s  .c o  m*/
private void macOSXRegistration() {
    final SystemUtilities systemUtils = new SystemUtilities();

    if (systemUtils.isMacPlatform() && !systemUtils.isApplet()) {
        try {
            final Class<?> osxAdapter = Class.forName("org.rivalry.swingui.util.OSXAdapter");

            final Class<?>[] defArgs = { OSXApp.class };
            final Method registerMethod = osxAdapter.getDeclaredMethod("registerMacOSXApplication", defArgs);

            if (registerMethod != null) {
                final Object[] args = { this };
                registerMethod.invoke(osxAdapter, args);
            }
        } catch (final NoClassDefFoundError e) {
            /*
             * This will be thrown first if the OSXAdapter is loaded on a system without the EAWT because OSXAdapter
             * extends ApplicationAdapter in its def
             */
            LOGGER.error(
                    "This version of Mac OS X does not support the Apple EAWT.  Application Menu handling has been disabled.",
                    e);
        } catch (final ClassNotFoundException e) {
            /*
             * This shouldn't be reached; if there's a problem with the OSXAdapter we should get the above
             * NoClassDefFoundError first.
             */
            LOGGER.error(
                    "This version of Mac OS X does not support the Apple EAWT.  Application Menu handling has been disabled.",
                    e);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}

From source file:org.deegree.services.controller.OGCFrontController.java

@Override
public void init(ServletConfig config) throws ServletException {

    instance = this;

    try {//w  w  w .j  a v  a  2  s.  co  m
        super.init(config);
        ctxPath = config.getServletContext().getContextPath();
        LOG.info("--------------------------------------------------------------------------------");
        DeegreeAALogoUtils.logInfo(LOG);
        LOG.info("--------------------------------------------------------------------------------");
        LOG.info("deegree modules");
        LOG.info("--------------------------------------------------------------------------------");
        LOG.info("");
        try {
            modulesInfo = extractModulesInfo(config.getServletContext());
        } catch (Throwable t) {
            LOG.error("Unable to extract deegree module information: " + t.getMessage());
            modulesInfo = emptyList();
        }
        for (ModuleInfo moduleInfo : modulesInfo) {
            LOG.info("- " + moduleInfo.toString());
            if ("deegree-services-commons".equals(moduleInfo.getArtifactId())) {
                version = moduleInfo.getVersion();
            }
        }
        if (version == null) {
            version = "unknown";
        }
        LOG.info("");
        LOG.info("--------------------------------------------------------------------------------");
        LOG.info("System info");
        LOG.info("--------------------------------------------------------------------------------");
        LOG.info("");
        LOG.info("- java version       " + System.getProperty("java.version") + " ("
                + System.getProperty("java.vendor") + ")");
        LOG.info("- operating system   " + System.getProperty("os.name") + " ("
                + System.getProperty("os.version") + ", " + System.getProperty("os.arch") + ")");
        LOG.info("- container          " + config.getServletContext().getServerInfo());
        LOG.info("- webapp path        " + ctxPath);
        LOG.info("- default encoding   " + DEFAULT_ENCODING);
        LOG.info("- system encoding    " + Charset.defaultCharset().displayName());
        LOG.info("- temp directory     " + defaultTMPDir);
        LOG.info("- XMLOutputFactory   " + XMLOutputFactory.newInstance().getClass().getCanonicalName());
        LOG.info("- XMLInputFactory    " + XMLInputFactory.newInstance().getClass().getCanonicalName());
        LOG.info("");

        initWorkspace();

    } catch (NoClassDefFoundError e) {
        LOG.error("Initialization failed!");
        LOG.error("You probably forgot to add a required .jar to the WEB-INF/lib directory.");
        LOG.error("The resource that could not be found was '{}'.", e.getMessage());
        LOG.debug("Stack trace:", e);

        throw new ServletException(e);
    } catch (Exception e) {
        LOG.error("Initialization failed!");
        LOG.error("An unexpected error was caught, stack trace:", e);

        throw new ServletException(e);
    } finally {
        CONTEXT.remove();
    }
}

From source file:org.apache.camel.impl.DefaultCamelContext.java

protected ManagementStrategy createManagementStrategy() {
    ManagementStrategy answer;/* www . ja va 2s .  co  m*/

    if (disableJMX || Boolean.getBoolean(JmxSystemPropertyKeys.DISABLED)) {
        log.info("JMX is disabled. Using DefaultManagementStrategy.");
        answer = new DefaultManagementStrategy();
    } else {
        try {
            log.info("JMX enabled. Using ManagedManagementStrategy.");
            answer = new ManagedManagementStrategy(new DefaultManagementAgent(this));
            // must start it to ensure JMX works and can load needed Spring JARs
            startServices(answer);
            // prefer to have it at first strategy
            lifecycleStrategies.add(0, new DefaultManagementLifecycleStrategy(this));
        } catch (NoClassDefFoundError e) {
            answer = null;

            // if we can't instantiate the JMX enabled strategy then fallback to default
            // could be because of missing .jars on the classpath
            log.warn("Cannot find needed classes for JMX lifecycle strategy."
                    + " Needed class is in spring-context.jar using Spring 2.5 or newer"
                    + " (spring-jmx.jar using Spring 2.0.x)." + " NoClassDefFoundError: " + e.getMessage());
        } catch (Exception e) {
            answer = null;
            log.warn(
                    "Cannot create JMX lifecycle strategy. Fallback to using DefaultManagementStrategy (non JMX).",
                    e);
        }
    }

    if (answer == null) {
        log.warn("Cannot use JMX. Fallback to using DefaultManagementStrategy (non JMX).");
        answer = new DefaultManagementStrategy();
    }

    // inject CamelContext
    if (answer instanceof CamelContextAware) {
        CamelContextAware aware = (CamelContextAware) answer;
        aware.setCamelContext(this);
    }

    return answer;
}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * @param value//from w  w w.  j a  va  2  s.c  om
 * @throws Exception
 */
private void showEditor(String value) throws Exception {

    if (value == null) {
        value = "";
    }

    try {
        sos.fckeditor.SOSFCKEditor editor = new sos.fckeditor.SOSFCKEditor(this.editorName);

        editor.setLanguage(this.sosLang);
        editor.setWidth(this.editorWidth);
        editor.setValue(value);
        editor.show(this.request, this.out);

    } catch (NoClassDefFoundError e) {
        throw new Exception("class not found : " + e.getMessage());
    } catch (Exception e) {
        throw new Exception("editor : " + e.getMessage());
    }

}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * Rechte fr die erste Ebene (Alle Applikationen) lesen
 * //  ww w  . ja va  2  s. c  om
 * @return boolean Fehlerzustand
 */

private boolean getTopLevelRights() throws Exception {
    this.debug(3, "getTopLevelRights");

    this.hasTopLevelWriteRight = true;
    this.hasTopLevelCreateRight = true;
    this.hasTopLevelReadRight = true;

    if (!this.topLevelAcl.equals("")) {
        if (this.user == null) {
            throw new Exception(this.rb.getMessage("sos.settings.dialog.err_acl_missing_user"));
        }

        try {
            sos.acl.SOSAcl acl = new sos.acl.SOSAcl(this.topLevelAcl);

            acl.setLocale(this.locale);

            if (this.debugLevel > 0) {
                acl.setOut(this.out);
                acl.setDebugLevel(this.debugLevel);
            }
            acl.setTableAcls(this.tableAcls);
            acl.setConnection(this.connection);

            acl.get(this.topLevelAcl);

            acl.access(this.user.getUserId(), this.user.getUserGroupIdList(), "rwdc");
            String op = acl.getResultOperations();

            if (op.indexOf('w') == -1) {
                this.hasTopLevelWriteRight = false;
                this.disabled = " disabled ";
            }

            if (op.indexOf('c') == -1) {
                this.hasTopLevelCreateRight = false;
            }

            if (op.indexOf('r') == -1) {
                this.hasTopLevelReadRight = false;
            }
        } catch (NoClassDefFoundError e) {
            throw new Exception("Class not found (sos.acl.jar) : " + e.getMessage());
        } catch (Exception e) {
            throw new Exception(SOSClassUtil.getMethodName() + " : " + e.getMessage());
        }
    }

    return true;
}

From source file:de.innovationgate.webgate.api.WGDatabase.java

private void createDBCoreObject(String strType) throws WGInvalidDatabaseException {
    Class dbClass;/*from   w  ww .jav  a2  s .c o  m*/
    try {
        dbClass = Class.forName(strType, true, WGFactory.getImplementationLoader());

        if (!WGDatabaseCore.class.isAssignableFrom(dbClass)) {
            throw new WGInvalidDatabaseException("Cannot allocate db type " + strType
                    + ": is no implementation of " + WGDatabaseCore.class.getName());
        }
        this.core = (WGDatabaseCore) dbClass.newInstance();
    } catch (ClassNotFoundException exc) {
        throw new WGInvalidDatabaseException(
                "Database implementation class or dependent class not found. Check classpath: "
                        + exc.getMessage());
    } catch (NoClassDefFoundError err) {
        throw new WGInvalidDatabaseException(
                "Database implementation class or dependent class not found. Check classpath: "
                        + err.getMessage());
    } catch (IllegalAccessException exc) {
        throw new WGInvalidDatabaseException(
                "Database implementation class or dependent class not accessible: " + exc.getMessage());
    } catch (InstantiationException exc) {
        throw new WGInvalidDatabaseException("Could not instantiate implementation class: " + exc.getMessage());
    }
}