Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:50:42+00:00 2026-05-29T19:50:42+00:00

Im trying to insert a keyspace into cassandra using hector and the SchemaManipulation example

  • 0

Im trying to insert a keyspace into cassandra using hector and the SchemaManipulation example given from the hector wiki.

package net.zanity.live;

import java.util.Arrays;
import java.util.List;

import me.prettyprint.cassandra.model.BasicColumnDefinition;
import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.cassandra.service.ThriftCfDef;
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.ddl.*;
import me.prettyprint.hector.api.exceptions.HectorException;
import me.prettyprint.hector.api.factory.HFactory;    

/**
 *
 * @author zznate
 *
 */
public class SchemaManipulation {

private static final String DYN_KEYSPACE = "YOUWantToSeeThis";
private static final String DYN_CF = "DynamicCf";
private static final String CF_SUPER = "SuperCf";

private static StringSerializer stringSerializer = StringSerializer.get();

public static void main(String[] args) throws Exception {

    Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");

    try {
        if ( cluster.describeKeyspace(DYN_KEYSPACE) != null ) {
          cluster.dropKeyspace(DYN_KEYSPACE);
        }

        BasicColumnDefinition columnDefinition = new BasicColumnDefinition();
        columnDefinition.setName(stringSerializer.toByteBuffer("birthdate"));
        columnDefinition.setIndexName("birthdate_idx");
        columnDefinition.setIndexType(ColumnIndexType.KEYS);
        columnDefinition.setValidationClass(ComparatorType.LONGTYPE.getClassName());

        BasicColumnFamilyDefinition columnFamilyDefinition = new BasicColumnFamilyDefinition();
        columnFamilyDefinition.setKeyspaceName(DYN_KEYSPACE);
        columnFamilyDefinition.setName(DYN_CF);
        columnFamilyDefinition.addColumnDefinition(columnDefinition);

        BasicColumnFamilyDefinition superCfDefinition = new BasicColumnFamilyDefinition();
        superCfDefinition.setKeyspaceName(DYN_KEYSPACE);
        superCfDefinition.setName(CF_SUPER);
        superCfDefinition.setColumnType(ColumnType.SUPER);



        ColumnFamilyDefinition cfDefStandard = new ThriftCfDef(columnFamilyDefinition);
        ColumnFamilyDefinition cfDefSuper = new ThriftCfDef(superCfDefinition);

        KeyspaceDefinition keyspaceDefinition = 
            HFactory.createKeyspaceDefinition(DYN_KEYSPACE, "org.apache.cassandra.locator.SimpleStrategy", 
                1, Arrays.asList(cfDefStandard, cfDefSuper));

        cluster.addKeyspace(keyspaceDefinition);

        // insert some data

        List<KeyspaceDefinition> keyspaces = cluster.describeKeyspaces();
        for (KeyspaceDefinition kd : keyspaces) {
            if ( kd.getName().equals(DYN_KEYSPACE) ) {
                System.out.println("Name: " +kd.getName());
                System.out.println("RF: " +kd.getReplicationFactor());
                System.out.println("strategy class: " +kd.getStrategyClass());
                List<ColumnFamilyDefinition> cfDefs = kd.getCfDefs();
                for (ColumnFamilyDefinition def : cfDefs) {
                  System.out.println("  CF Type: " +def.getColumnType());
                  System.out.println("  CF Name: " +def.getName());
                  System.out.println("  CF Metadata: " +def.getColumnMetadata());  
                }


            } 
        }


    } catch (HectorException he) {
        he.printStackTrace();
    }
    cluster.getConnectionManager().shutdown(); 
  }

}

The jsp code:

<%@page language="java" import="net.zanity.live.*" contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                   "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>GlassFish JSP Page</title>
  </head>
  <body>
    <% out.println("CAKrE"); Test test = new Test(); out.println("sting displayed here: " + test.Testt()); %>
    After this text loads the cassandra schema test will run and prolly crash the webapp
    <% SchemaManipulation cI = new SchemaManipulation(); SchemaManipulation.main(new String [0]);  %>
  </body>
</html> 

Im running this code in Eclipse 3.7.1 Indigo and the code when executed as a java application works and inserts into cassandra, but when i run it on the server it does not.

Cassandra is running on its default port as a local host and glasfish is also running on a local host on port 8080.

I think the issue is im not placing the hector jars in the correct place, the hector jars are already added to the buildpath but im not sure if that has added them to the server as well.

Any help would be appreciated as I’m failing to find useful documentation for cassandra.

EDIT: i have added the jar’s to the server that was not the problem, issue is still unresolved.

Stack Trace of errors:

WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:44)
    at me.prettyprint.cassandra.service.ThriftCluster.<init>(ThriftCluster.java:21)
    at me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:192)
    at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:139)
    at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:128)
    at net.zanity.live.SchemaManipulation.main(SchemaManipulation.java:36)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:61)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:50:43+00:00Added an answer on May 29, 2026 at 7:50 pm

    I think you just forgot to add also the slf4j jar.

    That should solve the problem.

    In fact the stack trace says it cannot find the class org.slf4j.LoggerFactory which is included in the slf4j jar.

    This jar is needed for hector, and indeed hector rises the exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to INSERT INTO a table using the input from another table.
I'm trying to insert a column into an existing DataSet using C#. As an
I am trying to insert ID values in stored procedure from .net and the
Trying to insert values with Unicode Chars into a MySQL-database using Delphi 2010 and
I'm trying to insert multiple rows using SqlCommand from C# to SQL Server. I'm
I'm trying to insert a System.DateTime into an Access database using a parameterized OleDbCommand
I'm trying to insert some symbols from LaTeX Math Symbols into my LaTeX document:
I'm trying to insert some new objects into a firebird database using NHibernate. I
Hi i am trying to insert the great syntaxhighlighter into an asp .net page
I'm trying to insert another table row into a table after calling from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.