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:com.espertech.esper.epl.db.DatabaseDSFactoryConnFactory.java

/**
 * Ctor.//from  w  ww. j  a  v  a2  s . com
 * @param dsConfig is the datasource object name and initial context properties.
 * @param connectionSettings are the connection-level settings
 * @throws DatabaseConfigException when the factory cannot be configured
 */
public DatabaseDSFactoryConnFactory(ConfigurationDBRef.DataSourceFactory dsConfig,
        ConfigurationDBRef.ConnectionSettings connectionSettings) throws DatabaseConfigException {
    this.connectionSettings = connectionSettings;

    Class clazz;
    try {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        clazz = Class.forName(dsConfig.getFactoryClassname(), true, cl);
    } catch (ClassNotFoundException e) {
        throw new DatabaseConfigException("Class '" + dsConfig.getFactoryClassname() + "' cannot be loaded");
    }

    Object obj;
    try {
        obj = clazz.newInstance();
    } catch (InstantiationException e) {
        throw new ConfigurationException("Class '" + clazz + "' cannot be instantiated");
    } catch (IllegalAccessException e) {
        throw new ConfigurationException("Illegal access instantiating class '" + clazz + "'");
    }

    // find method : static DataSource createDataSource(Properties properties)
    Method method;
    try {
        method = clazz.getMethod("createDataSource", Properties.class);
    } catch (NoSuchMethodException e) {
        throw new ConfigurationException("Class '" + clazz
                + "' does not provide a static method by name createDataSource accepting a single Properties object as parameter");
    }
    if (method == null) {
        throw new ConfigurationException("Class '" + clazz
                + "' does not provide a static method by name createDataSource accepting a single Properties object as parameter");
    }
    if (method.getReturnType() != DataSource.class) {
        throw new ConfigurationException("On class '" + clazz
                + "' the static method by name createDataSource does not return a DataSource");
    }

    Object result;
    try {
        result = method.invoke(obj, dsConfig.getProperties());
    } catch (IllegalAccessException e) {
        throw new ConfigurationException(
                "Class '" + clazz + "' failed in method createDataSource :" + e.getMessage(), e);
    } catch (InvocationTargetException e) {
        throw new ConfigurationException(
                "Class '" + clazz + "' failed in method createDataSource :" + e.getMessage(), e);
    }
    if (result == null) {
        throw new ConfigurationException("Method createDataSource returned a null value for DataSource");
    }

    dataSource = (DataSource) result;
}

From source file:org.apache.lens.server.session.TestSessionClassLoaders.java

/**
 * Check that DB specific classlaoders are available
 * @throws Exception/*w  ww . j a v a2  s  .c  o m*/
 */
@Test
public void testSessionClassLoader() throws Exception {
    LensSessionHandle sessionHandle = sessionService.openSession("foo", "bar", new HashMap<String, String>());
    LensSessionImpl session = sessionService.getSession(sessionHandle);
    session.setDbResService(sessionService.getDatabaseResourceService());
    // Loading test class should fail for default database.
    session.setCurrentDatabase("default");
    try {
        // Acquire should set classloader in current thread
        sessionService.acquire(sessionHandle);
        Class clz = Class.forName(TestDatabaseResourceService.TEST_CLASS, true,
                Thread.currentThread().getContextClassLoader());
        // Expected to fail
        Assert.fail("Should not reach here as default db doesn't have jar loaded");
    } catch (ClassNotFoundException cnf) {
        // Pass
    } finally {
        sessionService.release(sessionHandle);
    }

    // test cube metastore client's configuration's classloader
    try {
        // Acquire should set classloader in current thread
        sessionService.acquire(sessionHandle);
        Class clz = session.getCubeMetastoreClient().getConf()
                .getClassByName(TestDatabaseResourceService.TEST_CLASS);
        // Expected to fail
        Assert.fail("Should not reach here as default db doesn't have jar loaded");
    } catch (ClassNotFoundException cnf) {
        // Pass
    } finally {
        sessionService.release(sessionHandle);
    }

    LOG.info("@@ Teting DB2");

    // Loading test class should pass for DB1
    session.setCurrentDatabase(DB1);
    try {
        sessionService.acquire(sessionHandle);

        ClassLoader thClassLoader = Thread.currentThread().getContextClassLoader();
        Assert.assertTrue(thClassLoader == session.getClassLoader(DB1));

        Class clz = Class.forName(TestDatabaseResourceService.TEST_CLASS, true, thClassLoader);
        Assert.assertNotNull(clz);
        // test cube metastore client's configuration's classloader
        clz = null;
        clz = session.getCubeMetastoreClient().getConf().getClassByName(TestDatabaseResourceService.TEST_CLASS);
        Assert.assertNotNull(clz);
    } catch (ClassNotFoundException cnf) {
        LOG.error(cnf.getMessage(), cnf);
        Assert.fail("Should not have thrown class not found exception: " + cnf.getMessage());
    } finally {
        sessionService.release(sessionHandle);
    }
    sessionService.closeSession(sessionHandle);
}

From source file:org.apache.rahas.impl.SAMLTokenIssuer.java

private SAMLAttributeStatement createSAMLAttributeStatement(SAMLSubject subject, RahasData rahasData,
        SAMLTokenIssuerConfig config) throws TrustException {
    try {/*from w  ww.j  av  a  2s . c o  m*/
        SAMLAttribute[] attrs = null;
        if (config.getCallbackHandler() != null) {
            SAMLAttributeCallback cb = new SAMLAttributeCallback(rahasData);
            SAMLCallbackHandler handler = config.getCallbackHandler();
            handler.handle(cb);
            attrs = cb.getAttributes();
        } else if (config.getCallbackHandlerName() != null
                && config.getCallbackHandlerName().trim().length() > 0) {
            SAMLAttributeCallback cb = new SAMLAttributeCallback(rahasData);
            SAMLCallbackHandler handler = null;
            MessageContext msgContext = rahasData.getInMessageContext();
            ClassLoader classLoader = msgContext.getAxisService().getClassLoader();
            Class cbClass = null;
            try {
                cbClass = Loader.loadClass(classLoader, config.getCallbackHandlerName());
            } catch (ClassNotFoundException e) {
                throw new TrustException("cannotLoadPWCBClass",
                        new String[] { config.getCallbackHandlerName() }, e);
            }
            try {
                handler = (SAMLCallbackHandler) cbClass.newInstance();
            } catch (Exception e) {
                throw new TrustException("cannotCreatePWCBInstance",
                        new String[] { config.getCallbackHandlerName() }, e);
            }
            handler.handle(cb);
            attrs = cb.getAttributes();
        } else {
            //TODO Remove this after discussing
            SAMLAttribute attribute = new SAMLAttribute("Name", "https://rahas.apache.org/saml/attrns", null,
                    -1, Arrays.asList(new String[] { "Colombo/Rahas" }));
            attrs = new SAMLAttribute[] { attribute };
        }

        SAMLAttributeStatement attrStmt = new SAMLAttributeStatement(subject, Arrays.asList(attrs));
        return attrStmt;
    } catch (SAMLException e) {
        throw new TrustException(e.getMessage(), e);
    }
}

From source file:hydrograph.ui.dataviewer.window.DebugDataViewer.java

public void showDataInDebugViewer(final boolean filterApplied, final boolean remoteOkPressed) {
    Display.getDefault().asyncExec(new Runnable() {
        @Override/*from ww w  .  j ava2 s  .  co m*/
        public void run() {
            try {
                initializeDataFileAdapter(filterApplied, getConditions());
            } catch (ClassNotFoundException e) {
                Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
                Utils.INSTANCE.showDetailErrorMessage(
                        Messages.UNABLE_TO_LOAD_DEBUG_FILE + ": unable to load CSV Driver", status);
                logger.error("Unable to load debug file", e);
                if (dataViewerAdapter != null) {
                    dataViewerAdapter.closeConnection();
                }
                getShell().close();
            } catch (SQLException | IOException exception) {
                Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, exception.getMessage(),
                        exception);
                Utils.INSTANCE.showDetailErrorMessage(
                        Messages.UNABLE_TO_LOAD_DEBUG_FILE + ": unable to read view data schema/file", status);
                logger.error("Unable to load debug file", exception);
                if (dataViewerAdapter != null) {
                    dataViewerAdapter.closeConnection();
                }
                getShell().close();
            }
            loadDebugFileInDataViewer(remoteOkPressed);
        }
    });
}

From source file:com.buildml.model.impl.BuildStoreDB.java

/**
 * Create a new BuildStoreDB object.//from   ww w  . j a  v a  2s .co  m
 * 
 * @param databaseName The name of the database to create. For SQLite databases,
 * this is the path to the database file.
 * @param saveRequired True if this database must be explicitly "saved" before it's
 *        closed (otherwise the changes will be discarded).
 * @throws FileNotFoundException The database file can't be found, or isn't writable.
 * @throws IOException Problem when opening the database, or making a temporary working database.
 */
/* package private */
BuildStoreDB(String databaseName, boolean saveRequired) throws FileNotFoundException, IOException {

    /* make sure that the sqlite JDBC connector is available */
    try {
        Class.forName("org.sqlite.JDBC");
    } catch (ClassNotFoundException e) {
        throw new FatalBuildStoreError("Unable to access the SQLite driver", e);
    }

    /*
     * Ensure that the database name ends with .bml (if it doesn't already)
     */
    String fileToOpen;
    if (databaseName.endsWith(".bml")) {
        fileToOpen = databaseName;
    } else {
        fileToOpen = databaseName + ".bml";
    }

    /* save the user-facing name of the database file, for when we need to save */
    databaseFileName = new File(fileToOpen).getAbsolutePath();

    /*
     * If we want save/saveAs functionality, create a temporary database file
     * where the live changes will be made. We start by making a copy of the
     * user-facing database file into this temporary file.
     */
    this.saveRequired = saveRequired;
    if (saveRequired) {
        try {
            tempDatabaseFileName = File.createTempFile("temp", ".tmpbml").toString();
        } catch (IOException e) {
            throw new IOException("Unable to open " + fileToOpen + ". " + e.getMessage());
        }

        /*
         * If there's an existing database file that we're editing, make a copy of it. If
         * not, we simply open a new database with the temporary name.
         */
        if (new File(fileToOpen).exists()) {
            FileUtils.copyFile(new File(fileToOpen), new File(tempDatabaseFileName));
        }
        fileToOpen = tempDatabaseFileName;
    }

    /* 
     * Open/create the database. The sqlite database will be created as
     * a local disk file with a .bml extension.
     */
    try {
        dbConn = DriverManager.getConnection("jdbc:sqlite:" + fileToOpen);

    } catch (SQLException e) {
        /* provide a meaningful error message if the file simply can't be opened */
        if (e.getMessage().contains("Permission denied")) {
            throw new FileNotFoundException("Error: Unable to open database file: " + fileToOpen);
        }

        /* else provide a more generic message */
        throw new FatalBuildStoreError(
                "Unable to access to SQLite database: " + fileToOpen + "\n" + e.getMessage());
    }

    /* prepare some statements */
    lastRowIDPrepStmt = prepareStatement("select last_insert_rowid()");

    /* performance tuning for the database */
    long maxMemory = Runtime.getRuntime().maxMemory();
    if (maxMemory != Long.MAX_VALUE) {
        /* 
         * Set the SQLITE in-memory page cache to 30% of available memory. 
         * This makes the database really fast, although does tend to take up memory.
         */
        int cache_size = (int) (maxMemory / 1024 * 0.3);
        if (cache_size < 2000) {
            cache_size = 2000;
        }
        executeUpdate("pragma cache_size=" + cache_size);
    }
}

From source file:lu.fisch.moenagade.model.Project.java

private boolean compile() {
    // get all the files content
    Hashtable<String, String> codes = new Hashtable<>();
    String dir = directoryName + System.getProperty("file.separator") + "src";
    Collection files = FileUtils.listFiles(new File(dir), new String[] { "java" }, true);
    for (Iterator iterator = files.iterator(); iterator.hasNext();) {
        File file = (File) iterator.next();
        try {//from  w ww.ja  v  a2  s  .  c om
            codes.put(
                    file.getPath().substring(dir.length() + 1)
                            .replace(System.getProperty("file.separator"), ".").replace(".java", ""),
                    IOUtils.toString(file.toURI(), "utf-8"));
        } catch (IOException ex2) {
            JOptionPane.showMessageDialog(frame,
                    "Error while saving world (base) source!\n" + ex2.getMessage() + "\n", "Error",
                    JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR);
            ex2.printStackTrace();
            return false;
        }
    }

    // compile 
    try {
        //Runtime6.getInstance().executeCommand("System.setProperty(\"user.dir\",\"" + directoryName + "\")");
        Runtime6.getInstance().setRootDirectory(directoryName + System.getProperty("file.separator") + "src");
        Runtime6.getInstance().compile(codes, "");
        //Runtime6.getInstance().compileToPath(sourceFiles, directoryName+System.getProperty("file.separator")+"bin", "7", "");
    } catch (ClassNotFoundException ex) {
        JOptionPane.showMessageDialog(frame, "Error while compiling!\n" + ex.getMessage() + "\n", "Error",
                JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR);
        Console.disconnectAll();
        ex.printStackTrace();
        Console.connectAll();
        return false;
    }

    return true;
}

From source file:org.cloudifysource.esc.driver.provisioning.ElasticMachineProvisioningCloudifyAdapter.java

@Override
public void afterPropertiesSet() throws Exception {

    logger = java.util.logging.Logger.getLogger(ElasticMachineProvisioningCloudifyAdapter.class.getName());

    final String cloudConfigDirectoryPath = findCloudConfigDirectoryPath();

    try {/*from  w  w  w.j  a va  2s .c  o m*/
        final String cloudOverridesPerService = config.getCloudOverridesPerService();

        initCloudObject(cloudConfigDirectoryPath, cloudOverridesPerService);

        this.cloudTemplateName = properties.get(CloudifyConstants.ELASTIC_PROPERTIES_CLOUD_TEMPLATE_NAME);

        if (this.cloudTemplateName == null) {
            throw new BeanConfigurationException("Cloud template was not set!");
        }
        // add additional templates from cloudConfigDirectory.
        addTemplatesToCloud(new File(cloudConfigDirectoryPath));
        final ComputeTemplate computeTemplate = this.cloud.getCloudCompute().getTemplates()
                .get(this.cloudTemplateName);
        if (computeTemplate == null) {
            throw new BeanConfigurationException("The provided cloud template name: " + this.cloudTemplateName
                    + " was not found in the cloud configuration");
        }

        // This code runs on the ESM in the remote machine,
        // so set the local directory to the value of the remote directory
        logger.info("Remote Directory is: " + computeTemplate.getRemoteDirectory());
        // if running a windows server.
        if (computeTemplate.getFileTransfer() == FileTransferModes.CIFS) {
            logger.info("Windows machine - modifying local directory location");
            final String remoteDirName = computeTemplate.getRemoteDirectory();
            final String windowsLocalDirPath = getWindowsLocalDirPath(remoteDirName,
                    computeTemplate.getLocalDirectory());
            logger.info("Modified local dir name is: " + windowsLocalDirPath);

            computeTemplate.setLocalDirectory(windowsLocalDirPath);
        } else {
            computeTemplate.setLocalDirectory(computeTemplate.getRemoteDirectory());
        }

        // load the provisioning class and set it up
        try {
            final ProvisioningDriverClassBuilder builder = new ProvisioningDriverClassBuilder();
            this.cloudifyProvisioning = builder.build(cloudConfigDirectoryPath,
                    this.cloud.getConfiguration().getClassName());
            // this.cloudifyProvisioning =
            // (ProvisioningDriver) Class.forName(this.cloud.getConfiguration().getClassName()).newInstance();

            if (cloudifyProvisioning instanceof ProvisioningDriverClassContextAware) {
                final ProvisioningDriverClassContext provisioningDriverContext = lazyCreateProvisioningDriverClassContext(
                        cloudifyProvisioning);
                final ProvisioningDriverClassContextAware contextAware = (ProvisioningDriverClassContextAware) cloudifyProvisioning;
                contextAware.setProvisioningDriverClassContext(provisioningDriverContext);
            }

            // checks if a service level configuration exists. If so, save
            // the configuration to local file and pass
            // to cloud driver.
            handleServiceCloudConfiguration();
            this.cloudifyProvisioning.setConfig(cloud, cloudTemplateName, false, serviceName);

            final String storageClassName = this.cloud.getConfiguration().getStorageClassName();
            if (StringUtils.isNotBlank(storageClassName)) {
                // instantiate the storage driver if defined.
                // even if no storage template is used, this is to allow
                // dynamic allocation at runtime.
                logger.info("creating storage provisioning driver.");
                this.storageProvisioning = (StorageProvisioningDriver) Class.forName(storageClassName)
                        .newInstance();
                this.storageTemplateName = config.getStorageTemplateName();
                if (this.storageProvisioning instanceof BaseStorageDriver) {
                    ((BaseStorageDriver) this.storageProvisioning)
                            .setComputeContext(cloudifyProvisioning.getComputeContext());
                }
                this.storageProvisioning.setConfig(cloud, this.cloudTemplateName);
                logger.info("storage provisioning driver created successfully.");
            }
        } catch (final ClassNotFoundException e) {
            throw new BeanConfigurationException(
                    "Failed to load provisioning class for cloud: " + this.cloud.getName()
                            + ". Class not found: " + this.cloud.getConfiguration().getClassName(),
                    e);
        } catch (final Exception e) {
            throw new BeanConfigurationException(
                    "Failed to load provisioning class for cloud: " + this.cloud.getName(), e);
        }

        this.lookupLocatorsString = createLocatorsString();

        logger.info("Locators string used for new instances will be: " + this.lookupLocatorsString);

    } catch (final DSLException e) {
        logger.severe("Could not parse the provided cloud configuration from : " + cloudConfigDirectoryPath
                + ": " + e.getMessage());
        throw new BeanConfigurationException("Could not parse the prvided cloud configuration: "
                + cloudConfigDirectoryPath + ": " + e.getMessage(), e);
    }

}

From source file:org.apache.myfaces.component.html.util.StreamingAddResource.java

public void serveResource(ServletContext context, HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    String pathInfo = request.getPathInfo();
    String uri = request.getContextPath() + request.getServletPath() + (pathInfo == null ? "" : pathInfo);
    String classNameStartsAfter = getResourceVirtualPath(context) + '/';

    int posStartClassName = uri.indexOf(classNameStartsAfter) + classNameStartsAfter.length();
    int posEndClassName = uri.indexOf(PATH_SEPARATOR, posStartClassName);
    String className = uri.substring(posStartClassName, posEndClassName);
    int posEndCacheKey = uri.indexOf(PATH_SEPARATOR, posEndClassName + 1);
    String resourceUri = null;/*from   w w w  . j a v a 2  s  . c o  m*/
    if (posEndCacheKey + 1 < uri.length()) {
        resourceUri = uri.substring(posEndCacheKey + 1);
    }

    try {
        Class resourceLoader = getClass(className);
        validateResourceLoader(resourceLoader);
        ((ResourceLoader) resourceLoader.newInstance()).serveResource(context, request, response, resourceUri);
        // response.flushBuffer();
        // Do not call response.flushBuffer buffer here. There is no point, as if there
        // ever were header data to write, this would fail as we have already written
        // the response body. The only point would be to flush the output stream, but
        // that will happen anyway when the servlet container closes the socket.
        //
        // In addition, flushing could fail here; it appears that Microsoft IE
        // hasthe habit of hard-closing its socket as soon as it has received a complete
        // gif file, rather than letting the server close it. The container will hopefully
        // silently ignore exceptions on close.            
    } catch (ClassNotFoundException e) {
        log.error("Could not find class for name: " + className, e);
        sendError(response, HttpServletResponse.SC_NOT_FOUND,
                "Could not find resourceloader class for name: " + className);
    } catch (InstantiationException e) {
        log.error("Could not instantiate class for name: " + className, e);
        sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "Could not instantiate resourceloader class for name: " + className);
    } catch (IllegalAccessException e) {
        log.error("Could not access class for name: " + className, e);
        sendError(response, HttpServletResponse.SC_FORBIDDEN,
                "Could not access resourceloader class for name: " + className);
    } catch (IOException e) {
        logSend.error("Error while serving resource: " + resourceUri + ", message : " + e.getMessage(), e);
        sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
    } catch (Throwable e) {
        log.error("Unknown error while serving resource: " + resourceUri + ", message : " + e.getMessage(), e);
        sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
    }
}

From source file:bds.clemson.nfv.ProviderLoader.java

@SuppressWarnings("unchecked")
private void configure(Properties properties) throws CloudException, InternalException, ConfigurationException,
        IllegalAccessException, InstantiationException {

    // First, read the basic configuration data from system properties
    String cname = properties.getProperty("DSN_PROVIDER_CLASS");
    String endpoint = properties.getProperty("DSN_ENDPOINT");
    String regionId = properties.getProperty("DSN_REGION");
    String cloudName = properties.getProperty("DSN_CLOUD_NAME", "Unkown");
    String providerName = properties.getProperty("DSN_PROVIDER_NAME", "Unknown");
    String account = properties.getProperty("DSN_ACCOUNT");

    // Use that information to register the cloud
    Cloud cloud;//  w w w . ja  v  a2 s . c om
    try {
        cloud = Cloud.register(providerName, cloudName, endpoint,
                (Class<? extends CloudProvider>) Class.forName(cname));
    } catch (ClassNotFoundException e) {
        throw new ConfigurationException("Unrecognized provider name '" + cname + "', is the jar included?");
    }

    // Find what additional fields are necessary to connect to the cloud
    ContextRequirements requirements = cloud.buildProvider().getContextRequirements();
    List<ContextRequirements.Field> fields = requirements.getConfigurableValues();

    // Load the values for the required fields from the system properties
    ProviderContext.Value[] values = new ProviderContext.Value[fields.size()];
    int i = 0;

    for (ContextRequirements.Field f : fields) {
        //            System.out.print("Loading '" + f.name + "' from ");
        if (f.type.equals(ContextRequirements.FieldType.KEYPAIR)) {
            //                System.out.println("'DSN_" + f.name + "_SHARED' and 'DSN_" + f.name + "_SECRET'");

            String sharedProperty = "DSN_" + f.name + "_SHARED";
            String secretProperty = "DSN_" + f.name + "_SECRET";
            String shared = properties.getProperty(sharedProperty);
            String secret = properties.getProperty(secretProperty);

            if (shared == null || secret == null)
                throw new ConfigurationException(
                        "Both " + sharedProperty + " and " + secretProperty + " properties are required.");

            // special case for p12 certificate (as in Google Cloud), from
            // https://groups.google.com/forum/#!topic/dasein-cloud/vAFgSZR09y0
            if (f.name.equals("p12Certificate")) {
                byte[][] bytes = new byte[2][];

                try {
                    bytes[0] = Files.readAllBytes(Paths.get(shared));
                } catch (IOException e) {
                    throw new ConfigurationException(e.getMessage());
                }

                bytes[1] = secret.getBytes();

                values[i] = new Value<byte[][]>(f.name, bytes);
            } else {
                try {
                    values[i] = ProviderContext.Value.parseValue(f, shared, secret);
                } catch (UnsupportedEncodingException e) {
                    throw new ConfigurationException(e.getMessage());
                }
            }
        } else {
            //                System.out.println("'DSN_" + f.name + "'");
            String propertyName = "DSN_" + f.name;
            String value = properties.getProperty(propertyName);

            if (value == null && f.required)
                throw new ConfigurationException("The " + propertyName + " property is required.");

            try {
                values[i] = ProviderContext.Value.parseValue(f, value);
            } catch (UnsupportedEncodingException e) {
                throw new ConfigurationException(e.getMessage());
            }
        }
        i++;
    }

    ProviderContext ctx = cloud.createContext(account, regionId, values);
    configuredProvider = ctx.connect();

}

From source file:org.apache.hadoop.hive.service.HSSessionItem.java

public List<FieldSchema> getColsFromJar(String DBName, String tableName) throws HiveServerException {
    l4j.info("in getColsFromJar DBName: " + DBName + " tableName :" + tableName);
    Descriptor message;/*  ww  w.j  a  v  a 2 s.c om*/
    String modified_time = null;
    String jar_path = null;
    l4j.info("dbName: " + DBName);
    l4j.info("tableName: " + tableName);
    try {
        modified_time = PBJarTool.downloadjar(DBName.toLowerCase(), tableName.toLowerCase(),
                SessionState.get().getConf());
    } catch (SemanticException e1) {
        // TODO Auto-generated catch block
        throw new HiveServerException(e1.getMessage());
    }
    jar_path = getHome() + "/auxlib/" + DBName.toLowerCase() + "_" + tableName.toLowerCase() + "_"
            + modified_time + ".jar";
    String full_name = PBJarTool.protobufPackageName + "." + DBName.toLowerCase() + "_"
            + tableName.toLowerCase() + "_" + modified_time + "$" + tableName.toLowerCase();
    boolean flag = SessionState.get().delete_resource(SessionState.ResourceType.JAR, jar_path);

    if (flag) {
        l4j.info("Deleted " + jar_path + " from class path");
    }
    SessionState.get();
    flag = SessionState.unregisterJar(jar_path);
    if (flag) {
        l4j.info("clear  " + jar_path + " from class path");
    }
    SessionState.get().add_resource(SessionState.ResourceType.JAR, jar_path);

    try {
        Class<?> outer = Class.forName(full_name, true, JavaUtils.getpbClassLoader());
        Method m = outer.getMethod("getDescriptor", (Class<?>[]) null);
        message = (Descriptor) m.invoke(null, (Object[]) null);
    } catch (ClassNotFoundException e) {
        throw new HiveServerException("Can't find Class: " + full_name + " check if " + DBName.toLowerCase()
                + "_" + tableName.toLowerCase() + "_" + modified_time + ".jar is created by makejar");
    } catch (Exception e) {
        throw new HiveServerException(e.getMessage());
    }
    List<FieldSchema> colList = new ArrayList<FieldSchema>();

    List<FieldDescriptor> fields = message.getFields();
    for (FieldDescriptor field : fields) {
        FieldSchema col = new FieldSchema();
        String name = field.getName();
        col.setName(name);
        String type = getTypeStringFromfield(field, true);
        col.setType(type);
        l4j.info("Xtodo !!add a col " + name + ": " + type);
        colList.add(col);
    }
    return colList;

}